QInputDialog::setInputMode doesn't work
Solved
General and Desktop
-
Hi, I've been trying to set up QInputDialog::setInputMode, but I can't seem to get it to work. Here's what I tried:
QInputDialog getCustomText; getCustomText.setInputMode(QInputDialog::InputMode (QInputDialog::UsePlainTextEditForTextInput)); qDebug() << getCustomText.inputMode(); //prints 0 if (getCustomText.exec() == QInputDialog::Accepted) { ... }
-
Because QInputDialog::UsePlainTextEditForTextInput is an InputDialogOption, not an InputMode
-
Because QInputDialog::UsePlainTextEditForTextInput is an InputDialogOption, not an InputMode
Hi @Christian-Ehrlicher, oh ok, but there are only 3 options, not including textEdit. Can I have QTextEdit instead of QLineEdit?
-
Hi,
Use the setOption method.
-
Hi,
Use the setOption method.
Hi @SGaist, thank you, that is what I was looking for. It works perfectly. Code:
QString text; QInputDialog getCustomText; getCustomText.setOption(QInputDialog::UsePlainTextEditForTextInput); getCustomText.setWindowTitle("Set a custom course"); getCustomText.setLabelText("Type in or paste an article."); if (getCustomText.exec() == QInputDialog::Accepted) { text = getCustomText.textValue(); }