setCancelButtonText not working
Solved
General and Desktop
-
Hi,
I've tried to change text of Cancel button in a QInputDialog, but this is not working.
My code is:
QInputDialog iD1;
iD1.setCancelButtonText(tr("&Cancel"));
m_host.username = iD1.getText(this, tr("Login error"),
tr("Invalid user account. Type username:"),
QLineEdit::Normal, m_host.username, &ok);
Cancel button is still the same like default after this code.
Do you have an idea for help me?
Thanks. -
Hi and welcome to devnet,
As stated in its documentation, getText is a static method therefore it won't make use of the instance you modified.
-
@Oreonan Don't use the static getText method, use your QInputDialog instance:
QInputDialog iD1; iD1.setCancelButtonText(tr("&Cancel")); iD1.setInputMode(QInputDialog::TextInput); iD1.exec(); m_host.username = iD1.textValue();