Results 1 to 6 of 6

Thread: [Dock Widget] Dynamically overlayed DockWidget

  1. #1
    Join Date
    Apr 2015
    Posts
    7
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Question [Dock Widget] Dynamically overlayed DockWidget

    Hello Everyone !

    I am trying to create a dynamical QDocWidget, and I was expecting it could be a native function but I didn't found it in the doc...

    I have a QDockWidget which is designed horizontally (QHBoxLayout), I set its parameters so that it can be docked on any Area of my mainWindow.
    What I would like is that :
    1. It could be docked really everywhere (I actually can't dock it on left and right areas)
    2. It would automatically change its layout according to the area its docked to


    Is there a function or a parameter that can do this ?
    Do i have to manually create a button that would switch the layout ?
    Is there any Signal emited when trying to "re-dock" a QDockWidget ?

    Thank you for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [Dock Widget] Dynamically overlayed DockWidget

    The dockwidget emits a dockLocationChanged() when it undocked or redocked

    Cheers,
    _

  3. #3
    Join Date
    Apr 2015
    Posts
    7
    Thanks
    3
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Cool Re: [Dock Widget] Dynamically overlayed DockWidget

    Quote Originally Posted by anda_skoa View Post
    The dockwidget emits a dockLocationChanged() when it undocked or redocked

    Cheers,
    _
    Thank you ! I managed to do what I wanted, I will explain my technique here maybe it can help someone.
    I Subclassed QDockWidget and then wrote a new SLOT:
    Qt Code:
    1. void MyQDockWidget::changeOrientation(Qt::DockWidgetArea area) {
    2. myLayout.clear;
    3. switch(area) {
    4. case Qt::TopDockWidgetArea:
    5. //set my new layout here
    6. break;
    7. case Qt::BottomDockWidgetArea:
    8. //set new Bot layout here
    9. break
    10. //do other layout if you need + default layout.
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    And then connected this slot with the mentionned above signal. It works great ! Thanks a lot.
    I got to say that I am pretty suprised that it is not a native SLOT in Qt. I guess it is a rarely used function...

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [Dock Widget] Dynamically overlayed DockWidget

    Not sure what you mean with native slot.
    The signal is part of the public/native API of QDockWidget, isn't it?

    Cheers,
    _

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

    Default Re: [Dock Widget] Dynamically overlayed DockWidget

    For a perfectionist, something lacking in your dynamic layout system is that the "gap object" (that blue rectangle showing the future dock location and geometry) will not have the same dynamic layout as the final docked widget.
    When you drag a vertical dock to the top or bottom regions, the blue preview region will have a certain geometry that is not reflected by the final dock geometry, which you're changing as soon as the dock is released.
    This can be confusing \ frustrating for some users, so be prepared to receive bug reports on this.

    Qt does have this dynamic layout for toolbars.

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,311
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: [Dock Widget] Dynamically overlayed DockWidget

    Not sure what you mean with native slot.
    The signal is part of the public/native API of QDockWidget, isn't it?
    I think he means: "Why isn't automatic layout reconfiguration a native part of Qt?" I think the answer to that should be pretty obvious.

Similar Threads

  1. Replies: 1
    Last Post: 10th August 2014, 21:06
  2. Replies: 1
    Last Post: 16th September 2009, 11:23
  3. Creating dock widget as tab dynamically
    By vidyadhar in forum Qt Programming
    Replies: 1
    Last Post: 18th July 2009, 12:03
  4. How to set proportion between dockwidget and central widget
    By christina123y in forum Qt Programming
    Replies: 6
    Last Post: 14th July 2009, 17:48
  5. How to put a DockWidget or Widget over others??
    By dungsivn in forum Qt Programming
    Replies: 6
    Last Post: 25th October 2007, 06:12

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
  •  
Qt is a trademark of The Qt Company.