PDA

View Full Version : aspect ratio of top-level widgets



urbangipsy
16th January 2007, 13:00
Hello everyone,
is there a cross-platform way of restraining the width/height ratio of a top-level widget to a fixed value in Qt 4.2 ?

thanks

André

guilugi
16th January 2007, 14:44
Maybe you can use a QBoxLayout with a single toplevel widget in it, and play with the horizontalStretch / verticalStretch parameters of the layout.

guilugi
16th January 2007, 14:47
Sorry for the double post !

Maybe you can use a QGridLayout with a single toplevel widget in it, and play with the stretch factors for column / row !

http://doc.trolltech.com/4.2/qgridlayout.html#setColumnStretch

urbangipsy
16th January 2007, 21:49
thanks, but unfortunately that's not what I want. If I'm not mistaken, your suggestions would only affect the inner layout of widgets. What I want is to constrain top-level widgets, ie actually the windows themselves. Qt should tell the windowing system that the widget's window has a special resizing policy.

What I tried until now was setting the resize policy for my widget to hasHeightForWidth() and reimplementing heightForWidth() (works only for child widgets) and issuing resizes by either calling QCoreApplication::postEvent or resize() in my resizeEvent-handler (infinite calling of resizeEvent(), as stated in the manual).