16 #include <QApplication>
19 #include <QMessageBox>
20 #include <QPushButton>
21 #include <QVBoxLayout>
25 , m_topLabel(new QLabel)
26 , m_comboSelector(new QComboBox)
27 , m_bottomLabel(new QLabel)
29 QColor bgColor(240, 240, 240, 255);
31 palette.setColor(QPalette::Window, bgColor);
32 setAutoFillBackground(
true);
35 setFixedSize(500, 250);
36 setWindowTitle(
"Please make a selection");
37 setWindowFlags(Qt::Dialog);
39 auto* topLayout =
new QHBoxLayout;
43 auto* mainLayout =
new QVBoxLayout;
44 mainLayout->addLayout(topLayout);
47 setLayout(mainLayout);
54 if (selection.contains(currentItem))
77 auto* result =
new QVBoxLayout;
79 QIcon icon = qApp->style()->standardIcon(QStyle::SP_MessageBoxQuestion);
81 auto* label =
new QLabel;
82 label->setPixmap(icon.pixmap(100));
84 result->addWidget(label);
85 result->addStretch(1);
86 result->setContentsMargins(0, 5, 0, 5);
95 auto* result =
new QVBoxLayout;
101 result->addStretch(1);
103 result->addStretch(1);
105 result->addStretch(1);
106 result->setContentsMargins(0, 5, 5, 5);
115 auto* result =
new QHBoxLayout;
117 auto* cancelButton =
new QPushButton(
"Cancel");
118 connect(cancelButton, &QPushButton::clicked,
this, &ComboSelectorDialog::reject);
120 auto* okButton =
new QPushButton(
"Try current selection");
121 connect(okButton, &QPushButton::clicked,
this, &ComboSelectorDialog::accept);
123 result->addStretch(1);
124 result->addWidget(okButton);
125 result->addWidget(cancelButton);
Defines class ComboSelectorDialog.
void addItems(const QStringList &selection, const QString ¤tItem="")
QBoxLayout * createLogoLayout()
Returns layout with icon for left part of the widget.
QBoxLayout * createButtonLayout()
Creates button layout with buttons.
ComboSelectorDialog(QWidget *parent=nullptr)
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.