playing around...
This commit is contained in:
parent
ffaca3ab13
commit
8bc8b8f44e
|
@ -0,0 +1,31 @@
|
|||
#include "guidededitor.h"
|
||||
|
||||
GuidedEditor::GuidedEditor(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
editorLayout = new FlowLayout(this);
|
||||
this->setLayout(editorLayout);
|
||||
//tests
|
||||
this->editorLayout->addWidget(new EditorElement(this));
|
||||
this->editorLayout->addWidget(new EditorElement(this));
|
||||
QString style = QString(
|
||||
"QWidget {"
|
||||
"border-radius: 5px;"
|
||||
"background: white }"
|
||||
"QLabel {border: 2px dashed black; background: gray; "
|
||||
"border-radius: 5px;}"
|
||||
"QLineEdit {border: 2px dashed black;background: dark-gray;"
|
||||
"border-radius: 5px;}"
|
||||
);
|
||||
this->setStyleSheet(style);
|
||||
|
||||
}
|
||||
|
||||
void GuidedEditor::addElement() {
|
||||
this->editorLayout->addWidget(new EditorElement(this));
|
||||
}
|
||||
|
||||
GuidedEditor::~GuidedEditor()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef GUIDEDEDITOR_H
|
||||
#define GUIDEDEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "flowlayout.h"
|
||||
#include "guidededitorelement.h"
|
||||
|
||||
class GuidedEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuidedEditor(QWidget *parent = 0);
|
||||
~GuidedEditor();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void addElement();
|
||||
|
||||
private:
|
||||
FlowLayout* editorLayout;
|
||||
QList<EditorElement*>* list;
|
||||
|
||||
};
|
||||
|
||||
#endif // GUIDEDEDITOR_H
|
|
@ -1,4 +1,4 @@
|
|||
#include "editorelement.h"
|
||||
#include "guidededitorelement.h"
|
||||
#include <QBoxLayout>
|
||||
|
||||
EditorElement::EditorElement(QWidget *parent) : QWidget(parent)
|
|
@ -1,27 +1,22 @@
|
|||
#include "mainwindow.h"
|
||||
#include "../QtGuidedEditor/qgewidget.h"
|
||||
#include "flowlayout.h"
|
||||
#include <QPushButton>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
list = new QList<EditorElement*>();
|
||||
editor = new QWidget(this);
|
||||
centralLayout = new FlowLayout(editor);
|
||||
editor->setLayout(centralLayout);
|
||||
centralLayout->addWidget(new EditorElement(this));
|
||||
centralLayout->addWidget(new EditorElement(this));
|
||||
editor = new GuidedEditor(this);
|
||||
this->setCentralWidget(editor);
|
||||
QString style = QString(
|
||||
"QWidget {"
|
||||
"border-radius: 5px;"
|
||||
"background: white }"
|
||||
"QLabel {border: 2px dashed black; background: gray; "
|
||||
"border-radius: 5px;}"
|
||||
"QLineEdit {border: 2px dashed black;background: dark-gray;"
|
||||
"border-radius: 5px;}"
|
||||
);
|
||||
editor->setStyleSheet(style);
|
||||
dockWidget = new QDockWidget(this);
|
||||
this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
|
||||
|
||||
// dockwidget
|
||||
QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget);
|
||||
dockWidget->setLayout(dockLayout);
|
||||
QPushButton* button = new QPushButton(dockWidget);
|
||||
button->setText("add");
|
||||
dockLayout->addWidget(button);
|
||||
this->connect(button, &QPushButton::pressed,editor, &GuidedEditor::addElement);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
10
mainwindow.h
10
mainwindow.h
|
@ -3,17 +3,17 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <QList>
|
||||
#include "editorelement.h"
|
||||
#include "flowlayout.h"
|
||||
#include "guidededitor.h"
|
||||
#include <QGridLayout>
|
||||
#include <QDockWidget>
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
FlowLayout* centralLayout;
|
||||
QWidget* editor;
|
||||
QList<EditorElement*>* list;
|
||||
|
||||
GuidedEditor* editor;
|
||||
QDockWidget* dockWidget;
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
|
|
|
@ -14,12 +14,14 @@ TEMPLATE = app
|
|||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
editorelement.cpp \
|
||||
flowlayout.cpp
|
||||
flowlayout.cpp \
|
||||
guidededitorelement.cpp \
|
||||
guidededitor.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
editorelement.h \
|
||||
flowlayout.h
|
||||
flowlayout.h \
|
||||
guidededitorelement.h \
|
||||
guidededitor.h
|
||||
|
||||
INCLUDEPATH += $$PWD/../QtGuidedEditor
|
||||
DEPENDPATH += $$PWD/../QtGuidedEditor
|
||||
|
|
Reference in New Issue