Results 1 to 7 of 7

Thread: how to use QSplitter class

  1. #1
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default how to use QSplitter class

    I want to know about using the append function in QSplitter so as to divide the child widgets into given proportions.........What would happen if I do:

    VideoPlayer::VideoPlayer() //A QSplitter type class
    {
    videoDisplayer = new VideoDisplayer(this);
    videoPlayerControls = new VideoPlayerControls(this);

    setOrientation(Qt::Vertical);
    playerSizeList.append(350);
    playerSizeList.append(100);
    setSizes(playerSizeList);
    }
    Does this divide the space taken by videoDisplayer and videoPlayerControls in the ratio 350:100??? or smthing similar??

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to use QSplitter class

    to realize a ration between two widgets better use QSplitter::setStretchFactor().

  3. #3
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: how to use QSplitter class

    Quote Originally Posted by Lykurg View Post
    to realize a ration between two widgets better use QSplitter::setStretchFactor().
    Please be more elaborate.............. I want to add that I do not want to "insert stretch".......... I want to divide two sub Widgets over a widget in a given proportion............say for example I have a "parent" widget and its two child widgets namely "Left" and "Right".............. So I want to divide the space occupied by Parent to Left and Right in the ratio 3:1.......Did u get me in the first go itself??

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to use QSplitter class

    If you always want a fix ratio you have to fetch the resize event and set the sizes yourself. Otherwise put the widgets in the right ratio to the splitter, then ensure with QSplitter::setStretchFactor() that new space will be divided in your wanted ratio.

  5. #5
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: how to use QSplitter class

    Quote Originally Posted by Lykurg View Post
    If you always want a fix ratio you have to fetch the resize event and set the sizes yourself. Otherwise put the widgets in the right ratio to the splitter, then ensure with QSplitter::setStretchFactor() that new space will be divided in your wanted ratio.
    Thanx a ton...................but could u elaborate the syntax :
    void QSplitter::setStretchFactor ( int index, int stretch )
    Plz could you elaborate with an example
    here how to use "index" and how much to kep the "stretch" for a 3:1 ratio?

  6. #6
    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 use QSplitter class

    Read "Stretch Factor" under "Layout Management" in Qt Assistant.

    Assuming a splitter with two widgets (0, 1):
    Qt Code:
    1. splitter->setStretchFactor(0, 3); // widget gets 3 out of 4 width/height units
    2. splitter->setStretchFactor(1, 1); // widget gets 1 out of 4 width/height units
    To copy to clipboard, switch view to plain text mode 
    Neither widget will shrink below its minimum size though.

  7. The following user says thank you to ChrisW67 for this useful post:

    qt_user (5th August 2010)

  8. #7
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: how to use QSplitter class

    thanx a ton........

Similar Threads

  1. Bug in QSplitter with Qt4.5.1
    By araglin in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2009, 07:45
  2. QSplitter
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2009, 13:46
  3. New to QSplitter
    By bruccutler in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2007, 16:43
  4. QSplitter synchronization
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2006, 17:22
  5. QSplitter
    By Solarity in forum Newbie
    Replies: 2
    Last Post: 10th February 2006, 17:05

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.