Set value for QInputDialog
#include <QInputDialog>
#include <QStringList>
#include <QApplication>
int main(int argc, char** argv) {
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
QStringList hobbits, yesno;
hobbits << "a" << "B" << "S" << "M" << "P";
yesno << "yes" << "no";
QString outcome, more, title("title");
QString query("a query");
do {
QString pick = QInputDialog::getItem(0, title, query, hobbits);
outcome = QString("You picked %1, try again?").arg(pick);
more = QInputDialog::getItem(0, "Pick a Hobbit", outcome, yesno, 1, false);
} while (more == "yes");
}
Related examples in the same category