I would like to use my own string on the button, in the the below mentioned functions "msgBox.setDefaultButton" and "msgBox.addButton" :
msgBox.setDefaultButton(QMessageBox::Save);
msgBox.addButton(QMessageBox::Abort);
instead of "Save" and "Abort", which are inbuilt, i would like to put my own text.
please let me know if its possible or please give me an alternative for above lines to create a button with my own random text.
ex :
msgBox.setDefaultButton(QMessageBox::"Lakshmi");
msgBox.addButton(QMessageBox::"Kanth");
TIA.
Regards, Lakshmikanth .G
QMessageBox::Save
and QMessageBox::Abort
are not variables where you take the text but are part of an enumeration and internally creates the buttons with the texts previously set. If you want to set custom texts the addButton()
function is overloaded:
void QMessageBox::addButton(QAbstractButton *button, ButtonRole role)
QPushButton *QMessageBox::addButton(const QString &text, ButtonRole role)
QPushButton *QMessageBox::addButton(StandardButton button)
So for your case you could use any of the other options as shown below:
QMessageBox w;
QPushButton* Lakshmi = w.addButton("Lakshmi", QMessageBox::YesRole);
w.addButton("Kanth", QMessageBox::NoRole);
w.setDefaultButton(Lakshmi);
w.show();