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>
|
#include <QBoxLayout>
|
||||||
|
|
||||||
EditorElement::EditorElement(QWidget *parent) : QWidget(parent)
|
EditorElement::EditorElement(QWidget *parent) : QWidget(parent)
|
|
@ -1,27 +1,22 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "../QtGuidedEditor/qgewidget.h"
|
#include <QPushButton>
|
||||||
#include "flowlayout.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
list = new QList<EditorElement*>();
|
editor = new GuidedEditor(this);
|
||||||
editor = new QWidget(this);
|
|
||||||
centralLayout = new FlowLayout(editor);
|
|
||||||
editor->setLayout(centralLayout);
|
|
||||||
centralLayout->addWidget(new EditorElement(this));
|
|
||||||
centralLayout->addWidget(new EditorElement(this));
|
|
||||||
this->setCentralWidget(editor);
|
this->setCentralWidget(editor);
|
||||||
QString style = QString(
|
dockWidget = new QDockWidget(this);
|
||||||
"QWidget {"
|
this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
|
||||||
"border-radius: 5px;"
|
|
||||||
"background: white }"
|
// dockwidget
|
||||||
"QLabel {border: 2px dashed black; background: gray; "
|
QVBoxLayout* dockLayout = new QVBoxLayout(dockWidget);
|
||||||
"border-radius: 5px;}"
|
dockWidget->setLayout(dockLayout);
|
||||||
"QLineEdit {border: 2px dashed black;background: dark-gray;"
|
QPushButton* button = new QPushButton(dockWidget);
|
||||||
"border-radius: 5px;}"
|
button->setText("add");
|
||||||
);
|
dockLayout->addWidget(button);
|
||||||
editor->setStyleSheet(style);
|
this->connect(button, &QPushButton::pressed,editor, &GuidedEditor::addElement);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
mainwindow.h
10
mainwindow.h
|
@ -3,17 +3,17 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "editorelement.h"
|
|
||||||
#include "flowlayout.h"
|
#include "flowlayout.h"
|
||||||
|
#include "guidededitor.h"
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QDockWidget>
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
FlowLayout* centralLayout;
|
GuidedEditor* editor;
|
||||||
QWidget* editor;
|
QDockWidget* dockWidget;
|
||||||
QList<EditorElement*>* list;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = 0);
|
MainWindow(QWidget *parent = 0);
|
||||||
|
|
|
@ -14,12 +14,14 @@ TEMPLATE = app
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
editorelement.cpp \
|
flowlayout.cpp \
|
||||||
flowlayout.cpp
|
guidededitorelement.cpp \
|
||||||
|
guidededitor.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
editorelement.h \
|
flowlayout.h \
|
||||||
flowlayout.h
|
guidededitorelement.h \
|
||||||
|
guidededitor.h
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../QtGuidedEditor
|
INCLUDEPATH += $$PWD/../QtGuidedEditor
|
||||||
DEPENDPATH += $$PWD/../QtGuidedEditor
|
DEPENDPATH += $$PWD/../QtGuidedEditor
|
||||||
|
|
Reference in New Issue