Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-96087

Expose QDockWidget tab bar in QMainWindow

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Widgets: Main Window
    • None
    • All

    Description

      In QMainWindow, tabifyDockWidget can be used to create a QTabBar for QDockWidgets.

      mainWindow->tabifyDockWidget(target, this);

      Access to the tab is currently a member (tabBar) in a private class and used here, for example

      QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const
      {
          QList<QDockWidget*> ret;
          const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget);
          if (info && info->tabbed && info->tabBar) {
              for(int i = 0; i < info->item_list.count(); ++i) {
                  const QDockAreaLayoutItem &item = info->item_list.at(i);
                  if (item.widgetItem) {
                      if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) {
                          if (dock != dockwidget) {
                              ret += dock;
                          }
                      }
                  }
              }
          }
          return ret;
      }
      

       

      I would like access to this tab bar exposed in QMainWindow as a public function.  

       

      QTabBar *getTabBar(QDockWidget *dockwidget);
      

      I would then be able to connect to the signals from the tab to receive notifications when a tab is selected. 

      connect(_tabBar, &QTabBar::currentChanged, this, &AlbumManager::onCurrentChanged);

      Using this, I can create dockable tabs and know when they are selected.

       Please add this function to QMainWindow so we can get signals from the dockable widgets tab bar.

       

      QTabBar *QMainWindow::getTabBar(QDockWidget *dockwidget) 
      { 
        QMainWindowLayout *windowLayout = qt_mainwindow_layout(this); 
        if (!windowLayout) { return nullptr; } 
        QDockAreaLayout *dockAreaLayout = windowLayout->dockAreaLayoutInfo(); 
        if (!dockAreaLayout) { return nullptr; } 
        const QDockAreaLayoutInfo *info = dockAreaLayout->info(dockwidget); 
        if (info && info->tabbed) { return info->tabBar; } 
        return nullptr; 
      }
      

       

      Better would be if QMainWindow adds setTabBar to user QTabBar as base clases. 

      A full class that implemented tabbed QDockWidgets would be even better, since I am limited to using QMainWindow to get this functionality.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            doug_rogers Doug Rogers
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes