Results 1 to 2 of 2

Thread: DockWidgetArea change and layout direction change

  1. #1
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default DockWidgetArea change and layout direction change

    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

  2. #2
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DockWidgetArea change and layout direction change

    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?

Similar Threads

  1. Axis direction change
    By ysnegirev in forum Qwt
    Replies: 1
    Last Post: 7th December 2009, 09:05
  2. change layout dynamicly
    By stella1016 in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2009, 16:40
  3. Dynamically change the layout
    By pippo42 in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2009, 13:01
  4. layout direction issues with QGraphicsScene
    By sanjayshelke in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2009, 23:23
  5. Hide widget, but not change layout
    By dimaz in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 14:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.