PDA

View Full Version : QDialog resize ?



allensr
25th January 2007, 17:36
I have a QDialog with a couple of radio buttons and a couple of group boxes in it that I layed out in Designer. Depending on which radio button is selected, I hide one of the two group boxes, which are layed out vertically. This causes the other group box (the one not hid) to stretch and fill out the dialog box and it doesn't look right. I would prefer the dialog box to shrink -- to include my radio buttons, group box and OK/Cancel buttons. How is the best way to do this?? In Designer with sizePolicy for the Dialog box? In code?

TIA.

Qt 4.1.4

wysota
25th January 2007, 18:55
AFAIR you have to use setFixedHeight() to force the height to be fixed on the height of the window without any of the boxes (they should be hidden). Then hiding each box should result in shrinking the dialog.

jpn
25th January 2007, 19:01
Could you consider putting the group boxes into a QStackedWidget? QStackedWidget would take the size hint of both group boxes into consideration.

wysota
25th January 2007, 19:11
Could you consider putting the group boxes into a QStackedWidget? QStackedWidget would take the size hint of both group boxes into consideration.
But it won't shrink the top level widget by itself. Layouts won't help with that as the dialog is not part of any layout.

wysota
25th January 2007, 19:52
A complete solution can be seen in the wiki: Expanding dialog (http://wiki.qtcentre.org/index.php?title=Expanding_Dialog).

The trick is to put a size constraint on the top level layout.

Usability
28th October 2007, 22:57
A complete solution can be seen in the wiki: Expanding dialog (http://wiki.qtcentre.org/index.php?title=Expanding_Dialog).

The trick is to put a size constraint on the top level layout.

Sure, this makes the dialog expand and shrink, but now the user cannot change the size. I am trying to do this with a dialog containing text fields, and then resizing the dialog is a big benefit to the user. On windows using MFC we accepted solutions like this, but QT is supposed to be better. QT3 was better, the extension mechanism solved this problem. Sadly there appears to be no solution in QT4.

Usability
28th October 2007, 23:41
I just noticed the old duo of setExtension and showExtension from QT3 does still exist and work in QT4.3.1!

So no problem currently. Lets hope the Trolls provide a scaleable alternative before they remove the extension mechanism.