17 #include <QApplication>
20 #include <QMessageBox>
21 #include <QPushButton>
22 #include <QVBoxLayout>
26 , m_topLabel(new QLabel)
27 , m_comboSelector(new QComboBox)
28 , m_bottomLabel(new QLabel)
30 QColor bgColor(240, 240, 240, 255);
32 palette.setColor(QPalette::Window, bgColor);
33 setAutoFillBackground(
true);
36 setFixedSize(500, 250);
37 setWindowTitle(
"Please make a selection");
38 setWindowFlags(Qt::Dialog);
40 auto topLayout =
new QHBoxLayout;
44 auto mainLayout =
new QVBoxLayout;
45 mainLayout->addLayout(topLayout);
48 setLayout(mainLayout);
55 if (selection.contains(currentItem))
78 auto result =
new QVBoxLayout;
80 QIcon icon = qApp->style()->standardIcon(QStyle::SP_MessageBoxQuestion);
82 auto label =
new QLabel;
83 label->setPixmap(icon.pixmap(100));
85 result->addWidget(label);
86 result->addStretch(1);
87 result->setContentsMargins(0, 5, 0, 5);
96 auto result =
new QVBoxLayout;
102 result->addStretch(1);
104 result->addStretch(1);
106 result->addStretch(1);
107 result->setContentsMargins(0, 5, 5, 5);
116 auto result =
new QHBoxLayout;
118 auto cancelButton =
new QPushButton(
"Cancel");
119 connect(cancelButton, &QPushButton::clicked,
this, &ComboSelectorDialog::reject);
121 auto okButton =
new QPushButton(
"Try current selection");
122 connect(okButton, &QPushButton::clicked,
this, &ComboSelectorDialog::accept);
124 result->addStretch(1);
125 result->addWidget(okButton);
126 result->addWidget(cancelButton);
Defines class ComboSelectorDialog.
Defines class DesignerHelper.
void addItems(const QStringList &selection, const QString ¤tItem="")
ComboSelectorDialog(QWidget *parent=0)
QBoxLayout * createLogoLayout()
Returns layout with icon for left part of the widget.
QBoxLayout * createButtonLayout()
Creates button layout with buttons.
void setTextTop(const QString &text)
void setTextBottom(const QString &text)
QComboBox * m_comboSelector
QString currentText() const
QBoxLayout * createInfoLayout()
Creates right layout with text and QComboBox selection.