Results 1 to 8 of 8

Thread: QSplitter like a "grid" splitter [Using qt 4.4]

  1. #1
    Join Date
    Mar 2009
    Location
    China
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QSplitter like a "grid" splitter [Using qt 4.4]

    Hi,

    my problem is the following

    I have several widgets I want to layout in a grid style and I also want to
    have the QSplitter sizing features.

    With QSplitter i only can layout the widgets horitzontally or vertically but
    not in a grid with a handle in the centre to resize the widgets at the same
    time.

    For example, if I have 4 widgets like this picture

    (such as 1.png in attachment)

    if I move the handle in the centre to the right then

    (such as 2.png in attachment)

    if I move the handle in the centre down then

    (such as 3.png in attachment)

    I've seen this kind of feature in some windows app's but I don't know if
    this is possible using qt 4.1.

    I would like to know if there's a way to do that with the actual
    QSplitter's. Although if somenone has tried something similar and can give
    some hints to do it with another classes to get a similar result

    Thanks.
    Attached Images Attached Images
    • File Type: png 1.png (601 Bytes, 26 views)
    • File Type: png 2.png (579 Bytes, 16 views)
    • File Type: png 3.png (570 Bytes, 13 views)
    Last edited by yandy; 19th March 2009 at 04:43. Reason: reformatted to look better

  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: QSplitter like a "grid" splitter [Using qt 4.4]

    We also can read small texts!

    In one orientation you have one QSpliter in the other you have two.
    Qt Code:
    1. QSplitter s1 = new QSplitter(Qt::Horizontal);
    2. QSplitter s2 = new QSplitter(Qt::Horizontal);
    3. // add 2 widgets to each of them
    4. QSplitter s3 = new QSplitter(Qt::Vertical);
    5. s3->addWidget(s1);
    6. s3->addWidget(s1);
    To copy to clipboard, switch view to plain text mode 

    Now connect s1 and s2: sX::splitterMoved( int pos, int index ) to sY->handle(index)::moveSplitter(pos). (and vice versa!)

    Not tested but should work.

  3. #3
    Join Date
    Mar 2009
    Location
    China
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: QSplitter like a "grid" splitter [Using qt 4.4]

    Quote Originally Posted by Lykurg View Post
    We also can read small texts!

    In one orientation you have one QSpliter in the other you have two.
    Qt Code:
    1. QSplitter s1 = new QSplitter(Qt::Horizontal);
    2. QSplitter s2 = new QSplitter(Qt::Horizontal);
    3. // add 2 widgets to each of them
    4. QSplitter s3 = new QSplitter(Qt::Vertical);
    5. s3->addWidget(s1);
    6. s3->addWidget(s1);
    To copy to clipboard, switch view to plain text mode 

    Now connect s1 and s2: sX::splitterMoved( int pos, int index ) to sY->handle(index)::moveSplitter(pos). (and vice versa!)

    Not tested but should work.
    Thank you for your reply.But,maybe, I haven't expressed my problem properly. I'd like to move the point at the cross centre of the 4 splitter widgets to resize all of them four at the same time.Not just move "up to down" or "left to right". Thanks
    Last edited by yandy; 19th March 2009 at 12:07. Reason: reformatted to look better

  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: QSplitter like a "grid" splitter [Using qt 4.4]

    then extend the sample by an own splitter handle for s3 (painted at the position of the handles s1/s2). Use mouse tracking to get the coordinates and emit proper signals which are connected to s1 and s2. Pack all in one widget with an function setWidgetInSplitter(...).
    Easy

  5. The following user says thank you to Lykurg for this useful post:

    yandy (19th March 2009)

  6. #5
    Join Date
    Mar 2009
    Location
    China
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Cool Re: QSplitter like a "grid" splitter [Using qt 4.4]

    Quote Originally Posted by Lykurg View Post
    then extend the sample by an own splitter handle for s3 (painted at the position of the handles s1/s2). Use mouse tracking to get the coordinates and emit proper signals which are connected to s1 and s2. Pack all in one widget with an function setWidgetInSplitter(...).
    Easy
    Thank you,Let me have a try

  7. #6
    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: QSplitter like a "grid" splitter [Using qt 4.4]

    Quote Originally Posted by yandy View Post
    Let me have a try
    Go on, that's some work to get thinks work right. When you are ready, share your knowledge with us

  8. #7
    Join Date
    Jan 2012
    Posts
    66
    Thanks
    20
    Thanked 2 Times in 2 Posts
    Platforms
    Windows

    Default Re: QSplitter like a "grid" splitter [Using qt 4.4]

    Quote Originally Posted by Lykurg View Post

    In one orientation you have one QSpliter in the other you have two.
    Qt Code:
    1. QSplitter s1 = new QSplitter(Qt::Horizontal);
    2. QSplitter s2 = new QSplitter(Qt::Horizontal);
    3. // add 2 widgets to each of them
    4. QSplitter s3 = new QSplitter(Qt::Vertical);
    5. s3->addWidget(s1);
    6. s3->addWidget(s1);
    To copy to clipboard, switch view to plain text mode 

    Now connect s1 and s2: sX::splitterMoved( int pos, int index ) to sY->handle(index)::moveSplitter(pos). (and vice versa!)

    Not tested but should work.
    This is an old thread, but I don't quite understand Lykurg's suggestion. moveSplitter() is a member of QSplitter, not QSplitterHandle. Further, it's a protected function. So I can't figure out how to get it to work. Any ideas?
    Last edited by wayfaerer; 21st March 2012 at 22:04.

  9. #8
    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: QSplitter like a "grid" splitter [Using qt 4.4]

    You could subclass it to access it, but you don't need it. It was mainly an example on how to do it theoretical. Use QSplitter::setSizes() to set the size of the spliter. (for that you have to create a custom slot!)
    Qt Code:
    1. void slotForS2Moved() {
    2. s1->setSizes(s2->sizes());
    3. }
    To copy to clipboard, switch view to plain text mode 

  10. The following user says thank you to Lykurg for this useful post:

    wayfaerer (22nd March 2012)

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.