Say there is a QHBoxLayout and some widgets in it. How to specify a widget width and hight in the layout, so that while resizing the widget which containes the layout the given width and hight stay constant?
A:
One (simple) way to do this is to use QWidget::setMinimumSize and QWidget::setMaximumSize functions to set minimum size and maximum size to be the same. Doing this will prevent widget from expanding and shrinking. E.g.
widget->setMinimumSize( 200, 100 );
widget->setMaximumSize( 200, 100 );
Of course you can set these values in QtDesigner also.
Darqan
2010-07-20 11:22:04
This is what I used. But I have asked for another kind of solution (may be a better one).
Narek
2010-07-20 11:26:52
+2
A:
You can use
void QWidget::setFixedSize ( int w, int h )
which Sets the width of the widget to w and the height to h. This will make the size of the particular widget fixed when the window is re-sized.
Also you can use the combination of these functions,
void QWidget::setFixedHeight ( int h )
and also
void QWidget::setFixedWidth ( int w )
whichever is required for your need.. Hope it helps.
liaK
2010-07-20 12:37:45