QDockWidget doesn't resize after add widget



  • Hi everyone,
    I'm using a QDockWidget in MainWindow. When I insert a widget (in my case a table) into the dock, it does not expand with the widget, but it expands to a fixed size and then the scrollbar appears.
    However, if the widget is smaller than this initial fixed size, the Dock fits.
    But I didn't set any minimum or maximum size.
    Here is the dock code:

    QDockWidget *pPropertyDock = new QDockWidget(this);
    pPropertyDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    pPropertyDock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
    pPropertyDock->setWindowTitle(DOCK_TITLE);
    pPropertyDock->setObjectName(DOCK_OBJECTNAME);
    addDockWidget(Qt::RightDockWidgetArea, pPropertyDock);
    

    According to what the documentation says, the Dock should be adapted to the child widget.
    I do not understand where this maximal initial width comes from.
    Anyway I can extend it by hand, but I would like to extend in automatic.

    I hope I explained myself

    Thank you


  • Moderators

    @Gianluca86 Is your dock widget in a layout?



  • I hope not to misunderstand the question, but anyway no, I created the Dock inside the Mainwindow (addDockWidget (Qt :: RightDockWidgetArea, pPropertyDock)), while in the mainWindow centralWidget there is another widget.
    To insert the table into the Dock I simply used the command "setWidget" of QDockWidget.



  • For more information:
    the "Dock Widgets Example" show the problem.


  • Qt Champions 2016

    @Gianluca86

    Hi
    Im not sure i understand.
    alt text

    So the issue is that the dock is smaller than the QListWidget?

    The dock seems to have the size from the area allocated when created.
    Since there it no way it can adjust the splitter or the mainwindow size, how would it grow to fit the widget?



  • So there is no way to adjust the area where the dock is allocated?
    Can you do it only by hand?


  • Qt Champions 2016

    @Gianluca86
    You can make main window bigger and move the splitter. then
    it should be bigger.


Log in to reply
 

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