Solved 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?
SGaist Lifetime Qt Champion last edited by
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 :(
jsulm Lifetime Qt Champion last edited by jsulm
@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.