[SOLVED] Custom QWidget has wrong height in QGridLayout
-
Hi everyone,
I made a widget derived from QWidget that is used inside a QGridLayout. The widget's size hint depends on some string it displays, which is usually a couple of short words. To handle line breaking, the widget also defines "heightForWidth":http://doc.qt.digia.com/4.8-snapshot/qwidget.html#heightForWidth. Its size policy is "QSizePolicy::Preferred":http://doc.qt.digia.com/qt/qsizepolicy.html#Policy-enum in both directions.When I just show the widget on its own as a top-level window, everything seems alright. However, when I insert it into a QGridLayout, the widget is rendered much too high. Outputting the height of the widget's rect() during the paint event reveals that the height is fixed at 480 px, regardless of how high the layout is. The size hint at that point recommends a height of only 17 px, same for heightForWidth.
Any idea where those 480 px could come from?
-
Ouch. Note to self: always check for calls to setMinimumSize, especially if the size you set comes from another widget that's not part of a layout yet.