Results 1 to 7 of 7

Thread: QDialog resize ?

  1. #1
    Join Date
    May 2006
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QDialog resize ?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    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.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDialog resize ?

    Could you consider putting the group boxes into a QStackedWidget? QStackedWidget would take the size hint of both group boxes into consideration.
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    Quote Originally Posted by jpn View Post
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog resize ?

    A complete solution can be seen in the wiki: Expanding dialog.

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

  6. The following 2 users say thank you to wysota for this useful post:

    allensr (29th January 2007), jpn (26th January 2007)

  7. #6
    Join Date
    May 2007
    Location
    England
    Posts
    56
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog resize ?

    Quote Originally Posted by wysota View Post
    A complete solution can be seen in the wiki: 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.

  8. #7
    Join Date
    May 2007
    Location
    England
    Posts
    56
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog resize ?

    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.

Similar Threads

  1. How to resize window with pushbutton
    By kaydknight in forum Newbie
    Replies: 2
    Last Post: 13th January 2007, 12:17
  2. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43
  3. Replies: 1
    Last Post: 28th July 2006, 14:10
  4. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32
  5. How to get a QDockWidget to auto resize?
    By bitChanger in forum Qt Programming
    Replies: 4
    Last Post: 6th January 2006, 16:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.