[solved] QInputDialog - change Cancel button text
-
i have here a code to display inptut dialog, what should i add to change Cancel button text?
@
bool ok = false;
QString input = QInputDialog::getText(0,Strings::uasNewUser,Strings::uasLoginName,QLineEdit::Normal,"",&ok);
if (ok) {
if (input != "") {
bool insert = true;
Sql sql;
if (sql.connect()) {
usernames = sql.getUsernames();
for (int i = 0; i < usernames.length(); ++i) {
if (usernames[i] == input) insert = false;
}
if (insert) {
sql.insertUser(input);
loadData();
showUserData(ui->users->count()-1);
} else {
QMessageBox::warning(0,Strings::uasUserExist,Strings::uasUserWithName + " '"+input+"' "+ Strings::uasExist );
}
}
} else {
QMessageBox::warning(0,Strings::uasEmptyUsernameTitle,Strings::uasEmptyUsername);
}
}@ -
Hi,
One way I see around this is to create your QInputDialog with the constructor and call
@setCancelButtonText()@on it.
-
@
QInputDialog inputDialog;
inputDialog.setInputMode(QInputDialog::TextInput);
inputDialog.setCancelButtonText("My text");@
how will i know that OK button was clicked?
how can i show the input dialog? -
Hi,
Using exec and checking its return value
-
-
exec doesn't return a boolean value, it's a QDialog::DialogCode which can be in this case mapped to a boolean value.
For the second part, yes.
-
ok thanks i have solved my problem
-
You're welcome !
Since you have all running now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)