PDA

View Full Version : How to resize programmatically like the user with the mouse?



youkai
3rd September 2008, 15:22
Hi.

I want to resize a dialog like the user can do with the mouse. An example:

The user cannot resize the dialog to 0 x 0 but if I call resize(0, 0) the dialog disappears.

I hope you now what I mean. :)

y.shan
3rd September 2008, 15:32
I assume that you want to fit your width and height to the minimum and maximum size hint



if (your_width < minimumSizeHint().width())
{
your_width = minimumSizeHint().width();
}
else if (your_width > maximumSizeHint().width))
{
your_width = maximumSizeHint().width();
}

if (your_height < minimumSizeHint().height())
{
your_height = minimumSizeHint().height();
}
else if (your_height > maximumSizeHint().height())
{
your_height = maximumSizeHint().height();
}

resize(your_width, your_height);

youkai
3rd September 2008, 15:36
That is just what I wanted. Thank you! :)

jpn
3rd September 2008, 17:41
See also QLayout::closestAcceptableSize().