Results 1 to 4 of 4

Thread: QDockWidget problems

  1. #1
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: QDockWidget problems

    Hello.
    I have a couple of problems with QDockWidgets.

    1) Using a UI designed with Qt Designer, in my test program I can't resize a particular docked dockwidget beyond a certain amount, like I have reached its "minimum width" value.
    The dock widget is empty, it has no content. When I change the "minimum width" value to something like 10px through Designer and manually resize the dock widget, it is still bound by a minimum value which is 79px -- the dock widget is still limited by this arbitrary value despite having no content.
    How can I set a minimum width \ height for my dock widgets and have they respect this?


    2) I'd like to have a 'dynamic layout' in a dock widget. I designed it vertically like the following, and I'd like for the content to be arranged horizontally when it's docked at the top or bottom of the main window:



    Those "cells" are tool buttons, so this dock widget looks like a tool bar -- I don't want to use an actual tool bar because a tool bar has limited dock areas and is always at the edge of the main window, whereas a dock widget can be nested and tabbed with the other dock widgets in many more interesting ways.
    The layouts offered in Designer seem to only allow one fixed direction at a time, so if I relocate that vertical dock widget to the top or bottom areas, the tool buttons are still vertical instead of being arranged horizontally.
    Is there a layout that changes depending on the area that the dock widget is docked? It's especially important that this layout works with that "blue preview" region that is displayed when you're about to drop a dock widget on a new area. If this layout change is done manually through code, the blue preview region would not reflect the end result of the dock widget, as far as I know, as it would show the preview of dropping the dock widget with the old layout instead of the new layout that is enacted manually by code.


    Added after 1 7 minutes:


    After some more experimentation, regarding #1, the arbitrary size seems to be imposed by the dock widget title bar.

    If I try to resize a dock widget to make the title bar have less than 79px width, it stops. Is there a way to remove this constraint?
    Last edited by Kryzon; 28th December 2014 at 01:25.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDockWidget problems

    According to the docs for QDockWidget:

    Appearance

    A QDockWidget consists of a title bar and the content area. The title bar displays the dock widgets window title, a float button and a close button. Depending on the state of the QDockWidget, the float and close buttons may be either disabled or not shown at all.

    The visual appearance of the title bar and buttons is dependent on the style in use.
    So if you want to turn those off (in which case your dock widget will probably cease to be movable or dockable because the title bar is what enables that), you're going to have to mess with the style settings (in QStyleOptionDockWidget or the style sheet). The buttons need a minimum width in order to remain visible.

    Probably your best solution for the orientation problem is to design two layouts for the widget contents, one for vertical orientation and one for horizontal orientation. When you receive the dockLocationChanged() signal, you show the appropriate layout and hide the other.

  3. The following user says thank you to d_stranz for this useful post:

    Kryzon (29th December 2014)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QDockWidget problems

    The stop as you resize the dockwidgets down is probably the behaviour of the splitter that is inserted by the QMainWindow. I suspect that QSplitter::childrenCollapsible() is false and stops at the largest dockwidget's size hint or some arbitrary minumum. If you can get a pointer to the splitter you might be able to check that.

  5. The following user says thank you to ChrisW67 for this useful post:

    Kryzon (29th December 2014)

  6. #4
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: QDockWidget problems

    I want to preserve the title bar. I just wish that the dock widget would reduce further than those 79px, even when empty.

    Quote Originally Posted by d_stranz View Post
    Probably your best solution for the orientation problem is to design two layouts for the widget contents, one for vertical orientation and one for horizontal orientation. When you receive the dockLocationChanged() signal, you show the appropriate layout and hide the other.
    That does work technically, but unfortunately the blue frame that shows a preview of the docked widget will show an innacurate size. When the layouts are switched the preview and the result will look different.

    Quote Originally Posted by ChrisW67 View Post
    The stop as you resize the dockwidgets down is probably the behaviour of the splitter that is inserted by the QMainWindow. I suspect that QSplitter::childrenCollapsible() is false and stops at the largest dockwidget's size hint or some arbitrary minumum. If you can get a pointer to the splitter you might be able to check that.
    The same happens if I float the dock widget and work on it alone, leaving the main window aside.
    When scaling a vertical dock widget in the horizontal dimension, it will stop at 79px width instead of reducing all the way to zero, for example, in case of an empty dock widget.
    It seems to be an arbitrary value, as even the title of the widget will be cut out and the end replaced with an ellipsis like so: "longWidgetTitl..."

    I'll try reporting this as a bug.
    (EDIT) Here's the report for reference: https://bugreports.qt-project.org/browse/QTBUG-43579
    Last edited by Kryzon; 29th December 2014 at 11:21.

Similar Threads

  1. QDockWidget inside QDockWidget
    By mqt in forum Qt Programming
    Replies: 3
    Last Post: 1st July 2013, 12:57
  2. Replies: 1
    Last Post: 7th December 2010, 21:46
  3. Replies: 2
    Last Post: 23rd July 2010, 14:53
  4. QDockwidget
    By peace_comp in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2008, 05:19
  5. QDockWidget
    By ToddAtWSU in forum Qt Programming
    Replies: 6
    Last Post: 29th November 2007, 13:37

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.