is it possible to restrict the length in a QInputDialog::getText
? For example, I want to restrict the length from the user input to 10 characters directly in the InputDialog. Unfortunately, there isn't a function like QInputDialog::setMaximum
.
Here's my current code:
QString input = QInputDialog::getText(this, tr("Find"), tr("Enter text:"), QLineEdit::Normal, "", nullptr, Qt::WindowFlags(), Qt::ImhDialableCharactersOnly);
if (input == "")
return;
else if (input.length() > 10)
{
QMessageBox::warning(this, tr("Invalid input", "Note #1"), tr("Input is too long."));
// This is this function name (calls itself again)
on_actionFind_triggered();
}
...