Question

According to you the doucmentation, QtGui.QMessageBox.information() function can be used to create a dialog box with many push buttons, using the following constants:

QMessageBox.Ok  An “OK” button defined with the AcceptRole .
QMessageBox.Open    A “Open” button defined with the AcceptRole .
QMessageBox.Save    A “Save” button defined with the AcceptRole .
QMessageBox.Cancel  A “Cancel” button defined with the RejectRole .
QMessageBox.Close   A “Close” button defined with the RejectRole .
QMessageBox.Discard     A “Discard” or “Don’t Save” button, depending on the platform, defined with the DestructiveRole .
QMessageBox.Apply   An “Apply” button defined with the ApplyRole .
QMessageBox.Reset   A “Reset” button defined with the ResetRole .
QMessageBox.RestoreDefaults     A “Restore Defaults” button defined with the ResetRole .
QMessageBox.Help    A “Help” button defined with the HelpRole .
QMessageBox.SaveAll     A “Save All” button defined with the AcceptRole .
QMessageBox.Yes     A “Yes” button defined with the YesRole .
QMessageBox.YesToAll    A “Yes to All” button defined with the YesRole .
QMessageBox.No  A “No” button defined with the NoRole .
QMessageBox.NoToAll     A “No to All” button defined with the NoRole .
QMessageBox.Abort   An “Abort” button defined with the RejectRole .
QMessageBox.Retry   A “Retry” button defined with the AcceptRole .
QMessageBox.Ignore  An “Ignore” button defined with the AcceptRole .
QMessageBox.NoButton    An invalid button.

It supports many features.

I've ben using the documentation for the QMessageBox class.

My question is, how do I change text of a push button in a message box?

Was it helpful?

Solution

The QMessageBox::setButtonText is what you need.

Edit:

Thanks to Bakuriu for pointing this out.

The setButtonText method mentioned above would work when used with PyQt/PySide library compiled against Qt4.3 or earlier. Source.

And for later versions, changing the text of a button would involve:

button = messageBox.button(which)

button.setText(text)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top