I'm using the nice feature in QMessageBox to optionally show detailed text to the user. However, the window after expansion is still fairly small, and one immediately tries to resize the window so more of the details are visible. Even after setting what I think are the proper settings it won't allow resizing.
Here's the relevant snippet of PyQt4 code:
mb = QMessageBox()
mb.setText("Results written to '%s'" % filename)
mb.setDetailedText(str(myData))
mb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
mb.setSizeGripEnabled(True)
Am I missing a step and/or is this at all possible?
This works, but only tested on Linux under Gnome 2. It resizes horizontally only unless the "show details" text is turned on, in which case it resizes in both directions. The "show details" button still resets it to the initial size, this is either a feature or a bug depending on your pov:
if you're looking to make a resizable message box, pls, check if code below would work for you:
here's how messagebox is called:
solution is taken from here
hope this helps, regards
This is the solution I would use. This doesn't make the dialog resizable, but it does make the dialog change itself to a sensible size when the details box is visible. I have unashamedly stolen some ideas from serge_gubenko's answer. Even if you'd rather implement his resizing I humbly offer some other improvements below.