Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDockWidget - how to tell if it is tabbed under or closed

QDockWidget - how to tell if it is tabbed under or closed

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by
    #1

    Hello,

    I want to determine if a QDockWidget is visible and if not if it is not visible because it is closed or because it is tabbed and underneath another QDockWidget.
    How can I tell the difference?

    isVisible() returns false in both cases.

    If I instead use tabifiedDockWidgets(QDockWidget) to check if the widget is docked together with other widgets also the ones that are not tabified but have been in the dock previously and then got closed will show up as well.

    So how can I tell the difference?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you explain what difference it makes ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • gde23G Offline
        gde23G Offline
        gde23
        wrote on last edited by
        #3

        I want to make the two following things:

        • If a Dockwidget is docked alone then the objectname in the titleBarWidget should be shown. If there is a tab (tabbar position north) then only the title in the tab, not again on the titlebarwidget shoult be shown.

        • I want to have a menu, where all the available dockwidgets are shown and are checkable. Depending on weather they are open or not they should be shown as checked/unchechecked, so I can restore them when they are closed.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          QDockWidget already provides a QAction for that.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • gde23G Offline
            gde23G Offline
            gde23
            wrote on last edited by
            #5

            Thanks for the hint with the QDockWidget::toggleViewAction()
            However this does not solve the problem with the double object name in the tiltebar and the tab.
            (Except I do some hack using the check-state from the action)

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @gde23 said in QDockWidget - how to tell if it is tabbed under or closed:

              tabifiedDockWidgets

              Just one thing, do you mean this methods return more than the docks currently tabbed with the one you are requesting the information from ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • gde23G Offline
                gde23G Offline
                gde23
                wrote on last edited by gde23
                #7

                Kind of.
                tabifiedDockWidgets() returns the Dockwidegts that are tabbed together with the one I request tabifiedDockWidgets() from. But also the widgets that were in the same dock, but then were closed. Pressing the (X)-Button just calls hide(), so I can reopen them when needed without loosing the Information in them, maybe I have implemented this wrong?

                EDIT: even if I just drag and drop the widgets out the one in the dock still "sees" the others beeing there but not the other way round.

                example:

                Widegt1 + Wigdet2+ WIdget3 all in one dock
                Then I drag and drop Widget1 and Widget2 to be floating, leaving only Widget3 in dock and print the output

                    QList<NiceDockWidget*> dock_widgets = findChildren<NiceDockWidget*>();
                    for(int i=0; i<dock_widgets.size(); i++)
                    {
                        std::cout << "----" << dock_widgets[i]->objectName().toStdString() << std::endl;
                        QList<QDockWidget*> sibling_dock_widgets = tabifiedDockWidgets(dock_widgets[i]);
                        for(int j=0; j<sibling_dock_widgets.size(); j++)
                        {
                            std::cout << sibling_dock_widgets[j]->objectName().toStdString() << std::endl;
                        }
                    }
                

                Output is:
                ----Widget1
                ----Widegt2
                ----Widegt3
                Widget1
                Widegt2

                so Widget3 still thinks that Widget1 and Widegt2 are in the dock as well.

                Also if I close Widegt1 and Widget2 tabifiedDockWidgets(Widget3) still returns them

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Can you provide a minimal compilable example that shows that behaviour ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • gde23G Offline
                    gde23G Offline
                    gde23
                    wrote on last edited by
                    #9

                    @SGaist Here is a zip file with a minimal working example.
                    To test it just drag all three Docks to a DockWidgetArea so they get tabbed.
                    Then drag one widget back to floating.

                    Now tabifiedDockWidgets() will return no widgets for the floating one (see qDebug() output). This is how it should be.

                    However, tabifiedDockWidgets() will return the floating widget when called for one of the other widgets. This is wrong in my opinion.

                    1 Reply Last reply
                    1

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved