setCancelButtonText not working
-
wrote on 2 Feb 2021, 19:44 last edited by
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.
-
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 :(Lifetime Qt Championwrote on 3 Feb 2021, 06:54 last edited by jsulm 2 Mar 2021, 06:55@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();
-
wrote on 3 Feb 2021, 19:28 last edited by
Thanks, it's exactly that I wanted.
Problem is solve.
1/5