Disabling user resizing for QDockWidget in QMainWindow



  • Hi,

    I want to forbid users to change the size of a DockWidgetArea. One manner is to make its contents fixed-size, but then if I want to resize() the QMainWindow I cant set the new size for the QDockWidget. How can I achieve this?

    Thanks in advance!


  • Moderators

    I'm not sure this is what you mean but you can control the max/min size of your dock inside the resize event of the main window.

    For example, if you want to keep the dock always 1/3 of the main window you can do something like this:
    @
    void MainWindow::resizeEvent(QResizeEvent * evt) {
    QMainWindow::resizeEvent(evt);
    ui->dockWidget->setMaximumWidth(evt->size().width() / 3);
    ui->dockWidget->setMinimumWidth(evt->size().width() / 3);
    }
    @



  • But how can I do to forbid the applications users to resize a QDockWidgetArea? I dont want it (if possible) and I dont want the cursors type to be changed from the normal arrow to the Qt::SplitVCursor for example


  • Moderators

    There is no QDockWidgetArea. You can restrict size of the dock area content. If the content has fixed size (eg. by setting min and max to same value like I shown) the handle to resize won't appear. QMainWindow handles this for you.


Log in to reply
 

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