[Interest] QMdiSubWindow doesn't adjust its size

John Weeks john at wavemetrics.com
Tue Feb 4 19:41:32 CET 2014


I have a moderately complex compound widget contained within a QMdiSubWindow. Certain user actions may cause the widgets to change size. Since everything is contained within layouts, I would expect the QMdiSubWindow to adjust its size, but it doesn't.

Initial appearance:


A user action causes changes:


I find that if I add a call to this code after any action that might change the sizes of the widgets it works correctly:
 	IgorApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
	infoWindow->rootWidget()->adjustSize();			// rootWidget() returns a pointer to the QMdiSubWindow widget

Without the call to processEvents() it doesn't adjust correctly.

If the application is run as a SDI application (the window shown above is then a top-level window) it works correctly.

Yes, it's a frameless window. That doesn't seem to affect the behavior.

I can create a very simple application with QMdiSubWindow that exhibits this behavior. I don't think it's caused by forgetting to enclose something in a layout at some level. A QMdiSubWindow, when resized adjusts the size of its internal widget. But the internal widget changing size doesn't seem to be noticed by QMdiSubWindow.

1) Is there a way to get a QMdiSubWindow to automagically adjust to its internal widget? It would be better to not have to sprinkle that bit of code all over the place.

2) What is processEvents() doing? Why is it necessary?

3) I don't like sprinkling calls to processEvents() all over my code. Is there some other way to achieve this?

Thanks for any insight you can provide.

-John Weeks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140204/8d21f53b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.png
Type: image/png
Size: 7681 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140204/8d21f53b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-3.png
Type: image/png
Size: 8268 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140204/8d21f53b/attachment-0001.png>


More information about the Interest mailing list