Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disabling user resizing for QDockWidget in QMainWindow
QtWS25 Last Chance

Disabling user resizing for QDockWidget in QMainWindow

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aidaqt
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    1
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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);
      }
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aidaqt
        wrote on last edited by
        #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

        1 Reply Last reply
        1
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved