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: !https://www.dropbox.com/lightbox/home?select=tab.PNG(Squeezed tabs)!

    https://www.dropbox.com/sh/xj02uino8v3ms04/AACYz74JCLgYrpwZW94Y5vSva?dl=0

    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:
    !http://i296.photobucket.com/albums/mm188/crossblades666/tabs.jpg(Tabs)!

    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))
    {
    tabifyDockWidget(pPreviousDocWidget,*itTabWidget);
    if (NULL == pPreviousDocWidget)
    {
    addDockWidget(Qt::RightDockWidgetArea, *itTabWidget);
    }

    (*itTabWidget)->setFloating(false);
    pPreviousDocWidget = (*itTabWidget);

    pPreviousDocWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    }
    }
    @


  • 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
    tabbar->setElideMode(Qt::ElideNone);
    @
    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
 

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