To many QDockWidget in one area

  • Hello!

    I have trouble with QDockWidgets. I have a lot tab that are docked on the right side. They are squeez and unreadable. Look img: ! tabs)!

    They should have some scrool bar or second bar line offset to left.

    Any idea?

  • Moderators

    QTabWidget by default extends to hold entire text and provides scroll buttons for tabs that don't fit:

    You seem to have custom styling applied. Check if you restrict the maximum size of the tab or disable scroll buttons.

  • Thanks for your response.

    Hmm I comment styles and problem still exists so this was not by style.

    This how do it:

    Set some options:
    setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks | QMainWindow::ForceTabbedDocks | QMainWindow::VerticalTabs);
    setTabPosition(Qt::RightDockWidgetArea, QTabWidget::East);
    setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::West);
    setTabPosition(Qt::BottomDockWidgetArea, QTabWidget::South);

    Create single tab:
    m_pObjects3DTab = new O3DM::Components::Objects3DTabWidget(tr("Objects 3D"),this); (title , parent, flag = 0 )
    m_pObjects3DTab->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );

    Tabify docks widget:
    std::vector<QDockWidget*>::iterator itTabWidget;
    for (itTabWidget = m_vTabWidgets.begin(); itTabWidget != m_vTabWidgets.end(); ++itTabWidget)
    if (NULL != (*itTabWidget))
    if (NULL == pPreviousDocWidget)
    addDockWidget(Qt::RightDockWidgetArea, *itTabWidget);

    pPreviousDocWidget = (*itTabWidget);


  • Moderators

    Sorry, I jumped to the answer too quickly.
    Seems that dock widgets behave a little different than QTabWidget by default. When you create a tabbed docks Qt creates a QTabBar dynamically with the elide mode set to eliding text.
    So you need to react to that (connect to dockLocationChanged and topLevelChanged signals of the docks). Then find the dynamic QTabBar and set the elision mode to none:
    auto tabbar = mainWindow->findChild<QTabBar*>(QString(), Qt::FindDirectChildrenOnly);
    if(tabbar) //might be null if there are no tabbed docks
    If there can be more than one tabbed areas use findChildren instead of findChild and iterate over the resulting list.

  • Ok problem solved...

    Thank you very much :)

Log in to reply