How can I get the location of a QDockWidget in its current dock area?



  • How can I get the location of a QDockWidget in its current dock area? For example, if I have a dock area split in half with two widgets, how can I query the framework to find out which one is on top and which one is on bottom? The user can, of course, be dragging and dropping QDockWidgets dynamically.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can use geometry for that.

    Hope it helps


  • Moderators

    I consider the docking system to be one of the weakest points of Qt widgets. It's quite limited when it comes to querying for the state/position of the docks. It only provides basic information like dock area of the dock and partial tabbing information. Not enough to actually record/restore the dock position reliably.

    Take a look at this example:
    Docks example

    There's no way to completely tell what is the relation between dock A and other docks. There's no (direct at least) API to tell what the order of tabbed items is and how to recreate. You could look for a QTabWidget parent in A but that's really relying on internal implementation.
    You also can't really use geometry of the docks because thet doesn't tell you the order they were split in. For example dock F could be split vertically with C and D or horizontally with E. No way to tell in the API :(
    On top of that there are quite a few bugs related to correct reporting of various state when floating docks and GroupedDragging flag are involved.
    All in all I'd steer away from trying to figure out the relation between docks if you can help it. It's unreliable at best and doable (to some degree) only if you put restrictions on the docks e.g. no nested or floating docks.



  • @Chris-Kawa

    I completely agree with your comment. What is sad it is in the same state for years.
    Any plans on improvement?


  • Moderators

    @alex_malyu said:

    Any plans on improvement?

    Widgets are not that actively developed these days, though there are some improvements in Qt 5.6. Unfortunately the pace is slow. A lot of very useful features are still missing and the new ones are quite buggy.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.