Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDockWidget split size



  • Hi all,

    I'm trying to set the size from some QDockWidget tabs but I'm getting lost with so much information in the forum (QsizePolicy, QSplitter,...). For example, looking at the picture below I would like to not show the QDockWidget with the red square but keep the smaller width of the two marked with the blue squares. At the moment, if I don't paint the red QDockWidget the other two in blue are occupying the whole available screen space.

    2c9fedf4-cc01-445e-aed1-2efce1fd975f-image.png

    Thanks in advance!


  • Lifetime Qt Champion

    Hi,

    So you would like to keep the "empty space" occupied ?



  • If you want the red are to not be a dockwidget then it will by default be the "central widget".
    If you then set the maximumSize of the Dockwidget to some value it wont be wider than that. Or if you put something into the central widget then it will also reclaim some space.



  • Hi,

    My target is to show a picture like a screen saver, and once the user clicks the blue docks then appears the dock in red color. So basically the logo can occupy all the space but the blue docks.

    I tried to set a maximum width to the dock but then the result becomes like this:
    edd5f29b-57bf-4144-8c5e-ce4adf3cb0ac-image.png

    I saw in another post that the solution could be related to the QSplitter, I've been playing with it as well without success....


  • Lifetime Qt Champion

    It looks like you need a central widget for that, no ?



  • I have a central widget where I added the left tab plus the dock manager that contains the docks. But I can't find the way to set the default size of them, at the beginning they fill the whole space splitting it equally divided.


  • Lifetime Qt Champion

    @avmg said in QDockWidget split size:

    I have a central widget where I added the left tab plus the dock manager that contains the docks. But I can't find the way to set the default size of them, at the beginning they fill the whole space splitting it equally divided.

    That sounds like you are not using QMainWindow's feature.

    Can you show the code you are using ?



  • On the Design editor I've added a widget that contains a FancyTabBar, a QStackedWidget, and a QMenuBar, therefore it looks like this:
    1dfe3b66-1b3f-4aba-adc4-3e05595e5bdc-image.png

    Now typing this I have realized what @gde23 and @SGaist were asking for, the dock manager is inside a layout from one of the QStackedWidget pages, not the central widget. It's a bit confusing but basically the left side tab "FancyTabBar" functionality is to select the visible QStackedWidget page. Each of them has inside a dock manager and for example one of them has the three docks from the picture below (two blues plus the red).
    8df9c2f4-5817-4277-87f0-2581ccbd86da-image.png

    Here is an example on how I create the docks and I insert them into the dock manager and finally into the layout:

    DockWidget_xy = new ads::CDockWidget("Mag-XY");
    DockWidget_xz = new ads::CDockWidget("Mag-XZ");
    DockWidget_yz = new ads::CDockWidget("Mag-YZ");
    DockWidget_xy->setFeatures(ads::CDockWidget::DockWidgetFeature::DockWidgetMovable);
    DockWidget_xz->setFeatures(ads::CDockWidget::DockWidgetFeature::DockWidgetMovable);
    DockWidget_yz->setFeatures(ads::CDockWidget::DockWidgetFeature::DockWidgetMovable);
    
    auto DockArea_bottom = m_DockManager_mag->addDockWidget(ads::BottomDockWidgetArea, DockWidget_xy);
        m_DockManager_mag->addDockWidget(ads::RightDockWidgetArea, DockWidget_xz,DockArea_bottom);
        m_DockManager_mag->addDockWidget(ads::RightDockWidgetArea, DockWidget_yz,DockArea_bottom);
    ui->layout_mag->addWidget(m_DockManager_mag);
    

  • Lifetime Qt Champion

    But why not use QMainWindow's dock feature ?



  • @avmg said in QDockWidget split size:

    CDockWidget

    Because this dock has a couple of things that were not possible on the "standard" version ( I can't remember exactly, maybe was only a graphical difference). The author says that all the properties are the same as the original dock feature. I saw the solution was something related to QSplitter but I haven't been able to achieve my goal yet.



  • Hi again,

    So far I couldn't find a solution to this. I have seen quite many people asking for the same thing but there are no solutions, resize(int w, int h) is not changing anything, might be some way to set the initial size of the docks...¿?


  • Lifetime Qt Champion

    Did you check the KDDockWidgets project ? They might have your issue handled.


Log in to reply