Results 1 to 5 of 5

Thread: How to get a QDockWidget to auto resize?

  1. #1
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question How to get a QDockWidget to auto resize?

    This QDockWidget contains a QGridLayout.

    At run time a user can right click on some widgets in another area and add them to the grid of this dock widget. The widgets just overlap and look bad until the user manually resizes the dock widget. When they manually expand the dock widget to an acceptable grid look, that becomes the minimum size. I've also noticed that if you toggle the dock window visibility off and then on it will resize to an appropriate minimum size.

    How can i get the dockwidget to auto resize?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get a QDockWidget to auto resize?

    Try QWidget::updateGeometry() or QGridLayout::update().

  3. #3
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get a QDockWidget to auto resize?

    I've tried:

    QGridLayout::update()
    QDockWidget::update()
    QDockWidget::updateGeometry()
    QDockWidget::resize(sizeHint())
    QDockWidget::resize(QGridLayout::sizeHint())

    none of these help.

  4. #4
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get a QDockWidget to auto resize?

    Ok, in my dock widget constructor i call setMinimumWidth(150). If i comment this line out then the dock widget auto resizes correctly.

    This may be an acceptable solution. Now the only undesirable behavior is that when the dock widget contains nothing in the grid, the window width is small. This makes the window title scrunched up and looks funny.

  5. #5
    Join Date
    Jan 2006
    Posts
    70
    Thanks
    13
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get a QDockWidget to auto resize?

    As a place holder I added a QLabel to the gridlayout in the contructor with a welcome message. This solves the width issue and auto resize works correctly.

Similar Threads

  1. Qt 4.4 QDockWidget resize problem
    By MarkSutton in forum Qt Tools
    Replies: 2
    Last Post: 27th September 2008, 09:55
  2. Replies: 5
    Last Post: 13th September 2008, 00:13
  3. Replies: 11
    Last Post: 11th August 2008, 10:14
  4. Replies: 1
    Last Post: 10th August 2008, 19:55
  5. QTextEdit auto resize
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 26th October 2007, 20:59

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.