Problem with not showing tabs in tabified QDockWidget?



  • Hi,
    I have QMainWindow, where I have:

    • centralWidget containing QWidget
    • statusBar
    • toolBar

    I have menu in main window with action actionAddDock. When that action is triggered there should be addNewDock slot called. That slot calls method addDock(QString title).
    But the reason I write is that when I call it first time the tab is not showing (QDockWidget is showing but without tab). Only when there is at least two QDockWidgets the tabs are showing up.

    constructor:
    @
    MyWindow::MyWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);

    setDockConfiguration();
    connect(ui.actionAddDock, SIGNAL(triggered(bool)),
      this, SLOT(addNewDock()));
    

    }
    @

    setDockConfiguration():
    @
    void MyWindow::setDockConfiguration()
    {
    setDockOptions(AnimatedDocks | AllowTabbedDocks | ForceTabbedDocks);
    setTabPosition(Qt::BottomDockWidgetArea, QTabWidget::North);
    setTabShape(QTabWidget::Rounded);
    }
    @

    addNewDock():
    @
    void MyWindow::addNewDock()
    {
    addDock("Test");
    }
    @

    addDock(QString title):
    @
    void MyWindow::addDock(QString title)
    {
    QDockWidget *newDock = new QDockWidget(title, this);
    newDock->setTitleBarWidget(new QWidget());
    newDock->setAllowedAreas(Qt::BottomDockWidgetArea);

    newDock->setFloating(false);
    newDock->setFeatures(QDockWidget::DockWidgetMovable 
    /*QDockWidget::DockWidgetClosable |
    QDockWidget::DockWidgetFloatable*/);
    addDockWidget(Qt::BottomDockWidgetArea, newDock);
    
    // Add docking widget to list QList<QDockWidget*> dockList;
    bool isEmpty = dockList.isEmpty();
    if(!isEmpty)
    {
      int index = dockList.size() - 1;
      tabifyDockWidget(dockList[index], newDock);
    }
    dockList.append(newDock);
    

    }
    @

    Is there any way to show tab when there is only one QDockWidget?


  • Moderators

    that's how it is implemented. So this is not supported.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.