Wanted - BASIC pop-up dialog
-
I am looking for suggestions - from an experienced , actual user , I did scan examples and they are too fancy.
I just want very basic , simple pop-up dialog to give users "input options" selection.
Single QString text to pass to the main widget.
Prefer something I can build in QDesigner - including events / SIGNAL / slot. -
QString s = QInputDialog::getText(parent, "String input dialog", "Type something here:");
-
-
Thanks, I started looking at QQuickWidget and quickly got lost...
Since I like to use QDesigner I am , for time being, trying "group box".
Run into two problems - cannot figure out how to get the combo box to show all entries.
My goal is to eliminate users "click this / click that" as much as possible - hence "open the combo box" when the main widget is open.
Secondly , using QDialog - similar issue - how to add plain combo box , not group box , to QDialog. ( But that can wait){// combobox code block
QComboBox *endDeviceCombobox = new QComboBox(ui->groupBox); //(ui.groupBox_2);
endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
endDeviceCombobox->setWindowTitle("Select entry ");
endDeviceCombobox->maxVisibleItems();
endDeviceCombobox->setEditable(false);
endDeviceCombobox->setDuplicatesEnabled(false);
endDeviceCombobox->setGeometry(QRect(190, 20, 111, 21));
endDeviceCombobox->setEditable(false);
endDeviceCombobox->setDuplicatesEnabled(false);
endDeviceCombobox->addItem("TEST entry 1 ");
endDeviceCombobox->addItem("TEST entry 2 ");
endDeviceCombobox->addItem("TEST entry 1 ");
endDeviceCombobox->addItem("TEST entry 2 ");
endDviceCombobox->addItem("TEST entry 1 ");
endDeviceCombobox->addItem("TEST entry 2 ");
endDeviceCombobox->addItem("TEST entry 1 ");
endDeviceCombobox->addItem("TEST entry 2 ");
endDeviceCombobox->show();
}// combobox code block -
Don't reinvent the wheel.
QInputDialog
serves exactly this purpose. If you want a combo with predefined values instead of single string then just useQInputDialog::getItem
:QStringList options {"TEST entry 1", "TEST entry 2", "TEST entry 3"}; QString result = QInputDialog::getItem(parent, "Combo dialog", "Select entry:", options, 0, false);