QDockWidget sizing before and after moving

  • I admit I'm confused.

    I have a program with subclassed QOpenGLWidgets inside QDockWidgets. The only size information these give out is a minimum size.

    I want to call setFeatures to lock them in place while a specific function runs, but this along with various other operations shrinks the dock areas down to the minimum size that will hold all the QDockWidgets. Presumably by calling adjustSize()

    If I manually undock any QDockWidget, including a dummy one I create for testing, and dock it again then this behaviour goes away, like adjustSize() is no longer called. I can resize the dock widgets to my heart's content and it keeps those sizes.

    My question is whether there's a way to change whatever this changes programmatically so that the dock areas no longer shrink? I've tried the usual commands to float and unfloat them.

  • Replying to myself here. I needed to find a way to set QDockAreaLayoutItem::KeepSize which it turns out gets set every time you load the main window state from, say, a temporary variable you just saved it to the line before.

    Hacky but it works.

  • @KevNull Hi,

    Are you using Qt5.10 ? I think you met this bug https://bugreports.qt.io/browse/QTBUG-65592
    more info here: https://stackoverflow.com/questions/48119969/qdockwidget-splitter-jumps-when-qmainwindow-resized

    I 'm using this workaround in the MainWindow constructor (as suggested by stackoverlow thread):

    resizeDocks(QList<QDockWidget*>() << ui->myDockWidget, QList<int>() << 40 , Qt::Horizontal);

  • @Gojir4 Thanks for the bug reference. I've added it to my code documentation.

Log in to reply

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