QMdiSubWindow incorrect size - some hint needed
-
Hello mates
I'm looking for a hint why instance of
QMdiSubWindow
, created by use ofQMdiArea->addSubWindow(myWidget)
has incorrect, too large height, as you can see on the picture:
left widget has set correct height set manually by resizing subwindow, right one is what itssizeHint()
return.
I also did a test of just displaying the myWidget, without putting it intoQMdiSubwindow
- the size was fine.What should I investigate deeper into?
Qt 5.15.2 MinGW 64-bit
-
I managed to find the reason. It was because verticalSpacer (the one which consumes space below Alphas To Overheat label) had set height to 40; when I put 0 there the window now is displayed in correct size.
Funny thing though, I recall I had to set that height because of some reasons, but don't remember what exactly.@ChrisW67 Thanks for hints mate, and trying to help.
-
@MasterBLB They are different sizes because the one on the left is showing less. For example see the corresponding highlighted areas in the your image.
This tells me that the content is not in a layout being managed by a Qt class. If it is meant to be in a layout then something is broken there, (possibly a break in the layout tree). If you are managing layout yourself then the logic needs attention I suspect.
-
@ChrisW67 You're right, the manually shrunk subwindow deducted some height from widgets Left/Right arm and torso indeed. Still, this is weird, as program compiled on Windows7, and using Qt 5.11.x (don't remember exactly the version) has the size correct:
-
@MasterBLB That's a lot to stuff into one UI file. I do not see anything overtly broken layout-wise in the UI file. However, the panels that are being truncated are not present in the file, just a placeholder QWidget that I assume you stuff a layout and widgets into programmatically.
Seems to me that left/right arm, left/right leg, left/centre/right torso elements are good candidates for QListWidget or QTableWidget (maybe with custom delegate). Alternatively, each placeholder widget could be placed inside a QScrollArea. On a similar note, QFormLayout might be useful in a few places.
This is my best guess at the variable size thing:
When you place a widget into QMdiSubWindow it will size itself on the basis of the size hint provided by the widget. This hint will, in general, be the aggregate of all subordinate widget and layout size hints, i.e. enough to display everything. This may include space for the Tags and Description group box that is not presently displayed in the screen shot.
When you display this widget in isolation it will size itself according to the geometry you have explicitly set in the UI design (1224x652)..
-
I managed to find the reason. It was because verticalSpacer (the one which consumes space below Alphas To Overheat label) had set height to 40; when I put 0 there the window now is displayed in correct size.
Funny thing though, I recall I had to set that height because of some reasons, but don't remember what exactly.@ChrisW67 Thanks for hints mate, and trying to help.
-