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. How to change docked DockWidget size in QMainWindow?

How to change docked DockWidget size in QMainWindow?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.1k Views 2 Watching
  • 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.
  • HarbH Offline
    HarbH Offline
    Harb
    wrote on last edited by
    #1

    Hello guys!

    I'am a newbie in Qt. Now I'am trying to make my first MDI application. And just at the beginning I have encountered ablolutely insurmountable obstacle :). I am adding QDockWidget to my QMainWindow through addDockWidget method. And I want to make QDockWidget to have a specified width. I'am trying to change width through resize() method, but i doesn't have any effect. In any case my QDockWidget is added to WidgetDockArea with default width! It seems that resize() method have effect only in float mode, but how to change width of DockWidget in Docked mode?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can use the setFixedWidth method on the QDockWidget you created.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • HarbH Offline
        HarbH Offline
        Harb
        wrote on last edited by
        #3

        Tnx for answer. But it will not work for me. I want my Dock Widget to be resizable during Runtime, but at the same time I want to set some initial Width for it. The problem is that I can change width of the DockWidget dragging it with my mouse. But I can't do the same by using resize() function. It seems that QMainWindow has some restricitons, but I have not found any in documentation.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          By default it will use sizeHint to determine the optimum size for your widget. You can either reimplement that function (for your widget, not the QDockWidget) or set the minimal width.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          HarbH 1 Reply Last reply
          1
          • SGaistS SGaist

            By default it will use sizeHint to determine the optimum size for your widget. You can either reimplement that function (for your widget, not the QDockWidget) or set the minimal width.

            HarbH Offline
            HarbH Offline
            Harb
            wrote on last edited by
            #5

            @SGaist Tnx, I think it will help

            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