PDA

View Full Version : Disable Maximize at Runtime



ericV
3rd November 2009, 11:22
Hi everyone,

I have stumbled on a problem. I have a "Main Window" sub-classed form QMainWindow which updates it minimum size depending on the Widgets that are set onto it.

On a systems with more than 1 monitor, this can mean that the minimum size is larger than the "maximized size", for this case i want to be able to disable the maximize Button on the title-bar until the minimum size is smaller or equal to the maximized size.

With the following code i can get the available size of the Screen (the maximized size):



QSize screenSize = qApp->desktop()->availableGeometry(qApp->desktop()->screenNumber(this)).size();


But for disabling the button on the title-bar i have only found the following:
void QWidget::setWindowFlags(Qt::WindowFlags flags )

void QWidget::overrideWindowFlags ( Qt::WindowFlags flags )

If I use setWindowFlags, then the window will flicker as it gets hidden and must be re-shown.

The override method worked better as it didn't cause any flicker, but it also didn't update the button properly. I am not quite sure which "update" method is needed in this case.

So, does anyone understand what i am talking about? :p

Thank you for reading..

Eric