How to change docked DockWidget size in QMainWindow?



  • 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?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

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



  • 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.


  • Lifetime Qt Champion

    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.



  • @SGaist Tnx, I think it will help


Log in to reply
 

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