Results 1 to 5 of 5

Thread: Applying size constraints to dock widgets

  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Applying size constraints to dock widgets

    I'm facing a small but very annoying trouble : I add dock widgets to a QMainWindow and I want them to be as small as possible (i.e. to leave more space to the central widget...) I set the size policy of the dock and of its widget to QSizePolicy::Maximum while setting the policy of the central widget to QSizePolicy::Expanding but there's still a waste of space (my goal is to make the dock as small as possible by default). Besides, if I use QSizePolicy::MinimumExpanding instead on the central widget, the layout goes mad and the main window gets bigger than the available screen space...

    Any hints?
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Applying size constraints to dock widgets

    What about if you set minimum heights for the docks and also use QSizePolicy::Minimum, while keeping the central widget at QSizePolicy::Expanding?

    This way the docks will get a size hint = their minimum size while the central widget will be allowed to exercise it's expanding size policy.

    I am not sure it works. Dock sizes are very sensitive to restrictions especially because of the main window's dock widget layout( it is somewhat complex and doesn't behave well for few cases, such as setting minimum sizes - both width and height for the docks - doing this will result in peculiar dock movement behavior and also empty space between the docks and/or the docks and central widget).

    Any way, you can try it.

    Regards

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Applying size constraints to dock widgets

    Quote Originally Posted by marcel View Post
    What about if you set minimum heights for the docks and also use QSizePolicy::Minimum, while keeping the central widget at QSizePolicy::Expanding?
    This doesn't help...

    Quote Originally Posted by marcel View Post
    Any way, you can try it.
    I tried a couple more things (including reimp of sizeHint()) without any kind of success and I finally decided to take a look at the dock widgets example... It did it!!! The Trolls, knowing what they were doing I guess , used a special trick of theirs : create a custom QFrame-based class to hold the "real" content of your widget, subclass its sizeHint() method according to your needs and set it as the widget() of your dock widget... It solved it all and I thought it might be worth mentioning in case someone stumble across the same issue...
    Current Qt projects : QCodeEdit, RotiDeCode

  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: Applying size constraints to dock widgets

    Well... yes, it seems like a trollish idea... Hiding everything useful from end users and exposing a limited interface instead of using it themselves

  5. #5
    Join Date
    Sep 2007
    Posts
    18
    Thanks
    3

    Default Re: Applying size constraints to dock widgets

    Hi Could you share that code here
    Iam using Qt 4.3.2 I dont see a frame being used in the dockWidgets example here

    I think we are refering 2 different versions of Qt here.
    Please share a snip of that code

    Quote Originally Posted by fullmetalcoder View Post
    This doesn't help...


    I tried a couple more things (including reimp of sizeHint()) without any kind of success and I finally decided to take a look at the dock widgets example... It did it!!! The Trolls, knowing what they were doing I guess , used a special trick of theirs : create a custom QFrame-based class to hold the "real" content of your widget, subclass its sizeHint() method according to your needs and set it as the widget() of your dock widget... It solved it all and I thought it might be worth mentioning in case someone stumble across the same issue...

Similar Threads

  1. How to movable dock widgets?
    By becond in forum Qt Tools
    Replies: 3
    Last Post: 21st February 2006, 20:57

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.