Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
setCancelButtonText not working
I've tried to change text of Cancel button in a QInputDialog, but this is not working.
My code is:
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?
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.
@SGaist Thanks for your quick answer. But, in this case, I can't change name of a button and in the mean time use gettext function?
I've read documentation but I've find nothing interesting :(
@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();
Thanks, it's exactly that I wanted.
Problem is solve.