As far as I can tell by a quick look at the source , there is no easy way to directly open the text of the part or really access to the button "Show details ...". The best way I could find was this:
- Iterate through all the buttons in the message box.
ActionRole
value with the ActionRole
role, as this corresponds to the "Show Details ..." button.- Call the
click
method manually.
Example code for this in action:
#include <QAbstractButton> #include <QApplication> #include <QMessageBox> int main(int argc, char *argv[]) { QApplication app(argc, argv); QMessageBox messageBox; messageBox.setText("Some text"); messageBox.setDetailedText("More details go here"); // Loop through all buttons, looking for one with the "ActionRole" button // role. This is the "Show Details..." button. QAbstractButton *detailsButton = NULL; foreach (QAbstractButton *button, messageBox.buttons()) { if (messageBox.buttonRole(button) == QMessageBox::ActionRole) { detailsButton = button; break; } } // If we have found the details button, then click it to expand the // details area. if (detailsButton) { detailsButton->click(); } // Show the message box. messageBox.exec(); return app.exec(); }
source share