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. Working with several QDockWidgets
Forum Updated to NodeBB v4.3 + New Features

Working with several QDockWidgets

Scheduled Pinned Locked Moved General and Desktop
18 Posts 5 Posters 17.7k 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.
  • G Offline
    G Offline
    genjix
    wrote on last edited by
    #7

    I found this:
    @void QDockWidget::visibilityChanged ( bool visible ) [signal]

    This signal is emitted when the dock widget becomes visible (or invisible). This happens when the widget is hidden or shown, as well as when it is docked in a tabbed dock area and its tab becomes selected or unselected.

    This function was introduced in Qt 4.3.@

    Although quite why there's no method to get that property, I don't know... And it's also not specific enough.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #8

      There is bound to be a method for the visibility property. A QDockWidget is a QWidget itself. QWidget has the property, so QDockWidget has it as well (probably even requires it).

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        genjix
        wrote on last edited by
        #9

        Yeah I don't mean when the dock widget can be seen, but I mean when the dock widget is the selected one on top in a set of tabs.

        I wrote this "small example (click here":http://www.qtcentre.org/attachment.php?attachmentid=5397&d=1288020905 - run qmake/make) to show what I mean. Just click show/hide button and notice your currently selected tab position. Is this a Qt bug?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #10

          Interesting... It seems to be switching to the previously selected widget. Can't say if it's a bug though. I'd need to check a bit more. You could do a search through the bug tracker though.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • G Offline
            G Offline
            genjix
            wrote on last edited by
            #11

            "This":http://bugreports.qt.nokia.com/browse/QTBUG-3420 is the closest bug I could find. Seems QDockWidgets are rather sparse in their api so far :) No way to see who's on top, get the tab orderings, find the layout of several dock widgets in the same area :)

            1 Reply Last reply
            0
            • G Offline
              G Offline
              genjix
              wrote on last edited by
              #12

              I found the answer:
              "http://developer.qt.nokia.com/faq/answer/how_can_i_check_which_tab_is_the_current_one_in_a_tabbed_qdockwidget":http://developer.qt.nokia.com/faq/answer/how_can_i_check_which_tab_is_the_current_one_in_a_tabbed_qdockwidget

              1 Reply Last reply
              0
              • G Offline
                G Offline
                genjix
                wrote on last edited by
                #13

                How can I see if a QDockWidget belongs to a particular tab bar?
                EDIT: this "http://doc.trolltech.com/4.7/qtabwidget.html":http://doc.trolltech.com/4.7/qtabwidget.html
                (see indexOf(widget))

                EDIT2: Or not. Spoke too soon!!! QDockWidgets use QTabBar but they don't use QTabWidget! So how am I meant to see which QDockWidget belongs to which QTabBar so I can restore the state? Very frustrating :(

                Here is my saving code (saving tab positions)
                @ tabWidgetsAll = self.parent().findChildren(QTabWidget, None)
                # tab widgets which contain QDockWidget
                tabWidgets = []
                if len(tabWidgets) > 0:
                print 'yay'
                for w in widgets:
                for tab in tabWidgetsAll:
                if tab in tabWidgets:
                continue
                if tab.indexOf(w) != -1:
                tabWidgets.append(tab)
                for tab in tabWidgets:
                self.activeTabs.append((tab, tab.currentIndex()))@

                In that snippet 'yay' is never printed, indicating that no QTabWidget's exist and that QDockWidget doesn't use that for tabifying itself.

                And here is the restoration code:
                @ for tab in self.activeTabs:
                tab[0].setCurrentIndex(tab[1])
                self.activeTabs = []@

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  genjix
                  wrote on last edited by
                  #14

                  any ideas?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    genjix
                    wrote on last edited by
                    #15

                    Can Qt add a QMainWindow::setDockAreaVisible(Qt::DockWidgetArea area, bool visible) to their API?

                    Looking at:

                    http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/widgets/qdockarealayout_p.h

                    It looks like a trivial change:
                    add to

                    @
                    class QDockAreaLayout
                    {
                    QDockAreaLayoutInfo hiddenDocks[4]; // hidden dock windows
                    bool dockHidden[4]; // initialise to false, false, false, false on initialiser
                    };
                    QDockAreaLayout::setVisible(QInternal::DockPosition pos, bool visible)

                    if (!visible) {
                    // copy
                    hiddenDocks[pos] = docks[pos];
                    dockHidden[pos] = true;
                    // clear the dock widget area
                    docks[pos].clear();
                    } else {
                    docks[pos] = hiddenDocks[pos];
                    }
                    @

                    And add to QMainWindow::setVisible(area, bool) which does:
                    layoutState.dockAreaLayout.setVisible(toDockPos(area), bool);
                    invalidate();

                    Hiding/showing a sidepanel is such a common use-case :) This is a really needed feature.

                    I made a "bug report here":http://bugreports.qt.nokia.com/browse/QTBUG-14725

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Franzk
                      wrote on last edited by
                      #16

                      Maybe it's time to (do a feature request|develop it yourself and do a merge request) for that. I'm not sure these suggestions will be picked up from devnet.

                      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        genjix
                        wrote on last edited by
                        #17

                        Right, but I don't want to waste time building my own Qt, adding that function to the API to have it rejected. Where can I ask whether it would be accepted if the code worked nicely?

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mgran
                          wrote on last edited by
                          #18

                          [quote author="genjix" date="1288186847"]Where can I ask whether it would be accepted if the code worked nicely?[/quote]

                          Could start with a feature request at "http://bugreports.qt.nokia.com":http://bugreports.qt.nokia.com. Or find the developers on the #qt-labs IRC channel on irc.freenode.net for a chat.

                          Project Manager - Qt Development Frameworks

                          1 Reply Last reply
                          0

                          • Login

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