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. Dock Widgets and tabs
Forum Updated to NodeBB v4.3 + New Features

Dock Widgets and tabs

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k 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
    GrahamL
    wrote on last edited by
    #1

    Hi
    In my application I have a set of docked widgets that are all tabbed.
    I have a menu to which I have added the action associated with the docked widget that enables me to toggle the viability of the widgets. This all works fine except for one niggle.
    Say I have 2 out of 3 of my widgets on display and then use the menu to make a 3rd visible. The 3rd widget does get added to the tabbed set of widgets but is not made the current tab.

    Does anyone have any hints on how I can make it the current tab

    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GrahamL
      wrote on last edited by
      #2

      Ok I can now demonstrate my problem -
      In my class I have
      @
      TabWidgetTest::TabWidgetTest(QWidget *parent)
      : QMainWindow(parent)
      {
      ui.setupUi(this);

      m_dockWidgets.append(new QDockWidget("Dock 1",this));
      m_dockWidgets.last()->setWidget(new Dock1Content(this));
      addDockWidget(Qt::BottomDockWidgetArea,m_dockWidgets.last());
      m_dockWidgets.last()->setAllowedAreas(Qt::BottomDockWidgetArea);

      m_action1 = m_dockWidgets.last()->toggleViewAction();
      m_action1->setData(0);
      connect(m_action1,&QAction::toggled,this,&TabWidgetTest::onViewToggled);

      m_dockWidgets.append(new QDockWidget("Dock 2",this));
      m_dockWidgets.last()->setWidget(new Dock2Content(this));
      addDockWidget(Qt::BottomDockWidgetArea,m_dockWidgets.last());
      m_dockWidgets.last()->setAllowedAreas(Qt::BottomDockWidgetArea);

      m_action2 = m_dockWidgets.last()->toggleViewAction();
      m_action2->setData(1);
      connect(m_action2,&QAction::toggled,this,&TabWidgetTest::onViewToggled);

      tabifyDockWidget(m_dockWidgets[0],m_dockWidgets[1]);
      }@

      In the slot I have
      @
      {
      QList<QTabBar*> tabBarList = findChildren<QTabBar*>();
      QTabBar* tabBar = NULL;
      if (!tabBarList.isEmpty())
      {
      tabBar = tabBarList.at(0);
      qDebug() << "Count = " << tabBar->count();
      }
      else
      {
      qDebug() << "No tab bar";
      }

      QAction* action = dynamic_cast<QAction*>(sender());

      if (action)
      {
      int data = action->data().toInt();
      qDebug() << checked << " " << data;
      }
      qDebug() << "";
      // m_dockWidgets[data]->raise();
      //}
      }
      @

      When the slot is called the tabbed widget that is to be added has not yet been added to the tab bar. and I cannot see a way of catching when a widget has been added to the tab bar.

      Is there a way in which this can be achieved?

      Thanks

      1 Reply Last reply
      0
      • ThirdStrandT Offline
        ThirdStrandT Offline
        ThirdStrand
        wrote on last edited by
        #3

        An ancient topic but one which I just encountered myself.

        Before calling raise();, add a call to qApp->processEvents(); This allows the new tab to render and "exist" before you send the function call to raise it. I am using Qt 5.12.

        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