Results 1 to 5 of 5

Thread: How to make QSplitter to split my widgets in right proportions?

  1. #1
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default How to make QSplitter to split my widgets in right proportions?

    I have some troubles with QSplitter Widget. I have quite advanced nested layouts but everything works except this one.
    I'll try to picture how this part of my layout looks like.

    QVBoxLayout
    - QSplitter
    - QTabWidget (with 2 tabs)
    - Widget derived from QTextEdit
    - QLabel

    The problem is that my QTextEdit Widget should behave in a way i set in its constructor(i.e.):
    {
    setMinimumHeight(120);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    }
    and for QTabWidget i set
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    but when i run my app QTextEdit takes most of the window splitted by these two.

    Tried to put first code (that in {}) to its parent constructor but nothing changes
    I probably don't understand yet fully QSizePolicy and things related...

    I want QTextEdit to has its minimal height all the time but in a opportunity to change it manually by handler and rest of the window should be given to QTabWidget.
    Could anyone help, give me some hints?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to make QSplitter to split my widgets in right proportions?

    From the docs (emphasis is mine):
    QSizePolicy::Minimum: The sizeHint() is minimal, and sufficient. The widget can be expanded, but there is no advantage to it being larger (e.g. the horizontal direction of a push button). It cannot be smaller than the size provided by sizeHint().
    Try QSizePolicy::Fixed... not that I can see a point to a splitter that cannot be moved.
    Last edited by ChrisW67; 5th January 2012 at 22:42.

  3. #3
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to make QSplitter to split my widgets in right proportions?

    Yes but i just thought that the second widget with Expanding policy predominates this one's policy.
    Will try with Fixed.

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make QSplitter to split my widgets in right proportions?

    Can you post some actual code how you create the layout?
    Do you set stretch on any of the items when adding them to the layout?

    Setting anything like minimum, preffered or fixed should work fine.

  5. #5
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to make QSplitter to split my widgets in right proportions?

    If you want one widget to expand more than another use the H/V Stretch... QSizePolicy::setHorizontalStretch, look for vertical in the same page and use the one you need in your project to set widget "space" as you like.

Similar Threads

  1. QSplitter and re-arranging widgets within
    By poppenspeler in forum Newbie
    Replies: 1
    Last Post: 19th October 2011, 21:48
  2. Widget proportions in QSplitter
    By godi in forum Qt Programming
    Replies: 4
    Last Post: 30th September 2011, 08:59
  3. Size proportions of widgets in QSplitter
    By Boron in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 18:25
  4. How to remove widgets from QSplitter?
    By mcb in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2009, 06:10
  5. How to set Widgets sizes with in QSplitter
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2007, 07:38

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.