18 #ifndef PROPERTIESEDITORDIALOG_H 19 #define PROPERTIESEDITORDIALOG_H 22 #include <QDialogButtonBox> 23 #include <QVBoxLayout> 24 #include <QAbstractButton> 46 setWindowTitle(editor->title());
48 editor->setParent(
this);
51 QVBoxLayout *vlayout =
new QVBoxLayout(
this);
52 vlayout->addWidget(editor);
53 QDialogButtonBox *button_box =
new QDialogButtonBox (QDialogButtonBox::Apply |
QDialogButtonBox::Cancel | QDialogButtonBox::Reset,
this);
54 vlayout->addWidget(button_box);
57 connect(button_box, &QDialogButtonBox::clicked, [editor, button_box,
this](QAbstractButton *button)
59 switch(button_box->buttonRole(button))
61 case QDialogButtonBox::RejectRole:
65 case QDialogButtonBox::ResetRole:
68 case QDialogButtonBox::ApplyRole:
80 #endif // PROPERTIESEDITORDIALOG_H The PropertiesEditorDialog class Create a dialog to edit some properties of a thing. Only create a instance of this class and call exec, all is done for you in this class. The first argument (a template) must be a subclass of QWidget and provide the 3 methods bellow : QString::title() void::apply() void::reset() You can subclass the interface PropertiesEditorWidget who provide all this methods. This dialog take ownership of the editor, so the editor will be deleted by this dialog.
PropertiesEditorDialog(T editor, QWidget *parent=nullptr)