PDA

View Full Version : DockWidgetArea change and layout direction change



mstegehu
5th March 2010, 15:35
Hello,

I wonder if it is possible to change the main layout direction of a dockwidget from vertical to horizontal if the DockArea is changed from left/right to top/bottom or visa versa.

How can that been done in a simple way?

I would think that using a QBoxLayout and QBoxLayout::setDirection would do the trick but my widget is created with the Designer that explicitly uses a Vertical or Horizontal layout.

Regards,

Marcel

SKolaMunn
21st February 2012, 21:24
I see this original question was from 2010 but other people may be wondering the same thing and I had a suggestion. But besides that, I do this without a ui file, and Marcel is correct, you can simply use QBoxLayout then setDirection to change the direction. However, I do have a problem. I originally make my dock widget full of custom button widgets lined up horizontally and placed at the top dock location, I set allowable areas to top, bottom, left and right, and I can move it to any of these places. However, after I move it and programmatically change the layout direction, so everything looks nice on the left dock, it will not let me manually drag it back to the top or bottom docks. I assume this is because it sees the widget as requiring a certain amount of vertical space? Any ideas how I can move my widget from the left dock to the top dock?

As for the Designer question, using a ui file, I wonder if you could just use a grid layout, and have all widgets across one row when at top or bottom and then move them all to be down one column when moved? That's what I was considering doing before I realized I could use QBoxLayout::setDirection.

It seems, though, that this would be a common requirement for users, to want to change the direction of the layout when the dock location is changed. Maybe something should be "built-in" to the QDockWidget class for this?