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. Add Dock Widgets, Stacked?
Qt 6.11 is out! See what's new in the release blog

Add Dock Widgets, Stacked?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 12.9k 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.
  • L Offline
    L Offline
    LiamMaru
    wrote on last edited by
    #1

    Alright, another itch I'd like to scratch. How do I add dock widgets programatically that are stacked on top of each other? At the moment, I place 5 calls to place 5 dock widgets like so:

    @ this->addDockWidget(Qt::LeftDockWidgetArea, DockA);
    this->addDockWidget(Qt::LeftDockWidgetArea, DockB);
    this->addDockWidget(Qt::LeftDockWidgetArea, DockC);
    this->addDockWidget(Qt::LeftDockWidgetArea, DockD);
    this->addDockWidget(Qt::LeftDockWidgetArea, DockE);
    @

    However, they'll all appear one under the other. With this many docks, this isn't really the default behavior I'm keen on. How can I add them stacked on top of each other (with the tabs at the bottom), still allowing users to rearrange them later if they want?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      By using QMainWindow::tabifyDockWidgets.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LiamMaru
        wrote on last edited by
        #3

        [quote author="peppe" date="1293465676"]By using QMainWindow::tabifyDockWidgets.[/quote]

        That's the ticket, seems straightforward, thanks :).

        Here's another one, how do I choose which tab is currently selected? Or is this purely determined by the order in which they're stacked?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          There's no API I'm aware of. You have to manually get the QTabBar instance (see QObject::findChildren), figure out which index your QDockWidget have, and call setCurrentIndex on the tab bar. Really strange that the bug has been closed without no explaination:

          http://bugreports.qt.nokia.com/browse/QTBUG-1181

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • L Offline
            L Offline
            LiamMaru
            wrote on last edited by
            #5

            [quote author="peppe" date="1293467757"]There's no API I'm aware of. You have to manually get the QTabBar instance (see QObject::findChildren), figure out which index your QDockWidget have, and call setCurrentIndex on the tab bar. Really strange that the bug has been closed without no explaination:

            http://bugreports.qt.nokia.com/browse/QTBUG-1181[/quote]

            Ouch, that's a pain in the butt, however nice to know I'm not missing the bleeding obvious (again!). I've just plugged in the following which does the job:

            @// Get the tab bar, grab the first one and go to the first tab.
            QList<QTabBar*> tabBars = this->findChildren<QTabBar*>();
            if(tabBars.count())
            {
            tabBars.first()->setCurrentIndex(0);
            }@

            Although I agree, this is a bit of a pain in the ass, it would be nice to be able to write:
            @
            this->raiseDock(theDock);
            @
            ... And have it on top.

            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