Results 1 to 10 of 10

Thread: QDockWidget Size

  1. #1
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDockWidget Size

    Hallo,

    i'm trying to convince a QDockWidget to resize itself to a proper size, but it alway takes away half of the window size. (at the bottom)

    It would be perfect if the QDockWidget resized itself always in a certain relation to the total size of the Window (as 1/4).

    I tried this, but it didn't help. A resize() also doesn't have any effect (I think because of the QLayout)

    EDIT: think of setVerticalPolicy where there's setHorizontalPolicy down there. It doesn't make any sense in the other way. What do I need to set for SizePolicy if I want him to use VerticalStretch?

    Qt Code:
    1. QSizePolicy sizePolicy2;
    2. sizePolicy2.setVerticalStretch(3);
    3. sizePolicy2.setHorizontalPolicy(QSizePolicy::Expanding);
    4. centralWidget2->setSizePolicy(sizePolicy2);
    5. //chat erstellen
    6. dockwidget=new QDockWidget(this);
    7. dockwidget->setAllowedAreas(Qt::AllDockWidgetAreas);
    8. addDockWidget(Qt::BottomDockWidgetArea, dockwidget);
    9. chatwidget=new Chat(dockwidget);
    10. dockwidget->setWidget(chatwidget);
    11. QSizePolicy sizePolicy;
    12. //sizePolicy.setHorizontalStretch(3);
    13. sizePolicy.setHorizontalPolicy(QSizePolicy::Minimum);
    14. sizePolicy.setVerticalStretch(1);
    15. dockwidget->setSizePolicy(sizePolicy);
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    Andre
    Last edited by kiker99; 7th February 2006 at 20:01.

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDockWidget Size

    doesn't anbody have an idea? it'd be enough if I could set the QDockWidget's size (without changing maximumSize), for example with setGeometry.

  3. #3
    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: QDockWidget Size

    Which Qt version do you use?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    84
    Thanks
    7
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDockWidget Size

    hi,

    i had the same problem. i couldn't figure out how to set the size of
    a dockwidget explicitly because it's size is gouverned by the splitter
    which handles the size of central widget and the dw. so as a workaround
    i save the state of the window (QMainWindow::saveState()) and
    restore the state on start up. if the user changes the size of
    the dockwidget the size is at least the same the next time.
    so only the first time the dw and central widget shares the size of
    the mainwindow equaly.

    jh

  5. #5
    Join Date
    Jan 2006
    Posts
    30
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget Size

    I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDockWidget Size

    Quote Originally Posted by jacek
    Which Qt version do you use?
    Qt4

    Quote Originally Posted by rianquinn
    I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.
    thanks. You're right, this sucks.

  7. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget Size

    Quote Originally Posted by rianquinn
    I am having the same problem. Although the suggested solution should work, this isn't a clean solution. Our customers don't want to have to resize everything on initail startup. I will put in a request to Trolltech to see if there is a better solution.
    Here's what I would do (and have done in the past): Once you have arranged the dockwindow exactly how you want it to appear to the user, save the window state. You now have a string in the config file/registry that you can hardcode and use with loadState() to set the dockwindow size programmatically. You can now remove your load/save code and leave the hardcoded setting (or leave your load/save code in place as you wish).
    Save yourself some pain. Learn C++ before learning Qt.

  8. #8
    Join Date
    Jan 2006
    Posts
    30
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget Size

    Here's what I would do (and have done in the past): Once you have arranged the dockwindow exactly how you want it to appear to the user, save the window state. You now have a string in the config file/registry that you can hardcode and use with loadState() to set the dockwindow size programmatically. You can now remove your load/save code and leave the hardcoded setting (or leave your load/save code in place as you wish).
    The problem with this idea is that our customers DON'T want to have to adjust the sizes, they want it a specific size at startup. We have strick requirements. This is known to be a bug, and will be fixed in version 4.2.

  9. #9
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidget Size

    Quote Originally Posted by rianquinn
    The problem with this idea is that our customers DON'T want to have to adjust the sizes, they want it a specific size at startup. We have strick requirements. This is known to be a bug, and will be fixed in version 4.2.
    I don't think you read what I wrote properly. My solution means that the customers don't have to adjust the size.
    Save yourself some pain. Learn C++ before learning Qt.

  10. #10
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDockWidget Size

    Is this really fixed in >=4.2.0?
    How to do it properly?

Similar Threads

  1. QDockWidget size
    By user in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2009, 20:35
  2. QT-wince and QHttp::readAll() trouble....
    By AcerExtensa in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 12th June 2008, 09:40
  3. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  4. Default size of a QListWidget inside a QDockWidget
    By rakuco in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2007, 08:01
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.