Results 1 to 5 of 5

Thread: Widget proportions in QSplitter

  1. #1
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Question Widget proportions in QSplitter

    Hello,

    I am having some problems with the widgets proportions in different QSplitter.

    I have 3 Qsplitter and four widgets of different classes (QTreeWidget, QFrame, QTableWidget and QWidget). I create the whole structure in QtDesigner having the design and hierarchy shown in pictures 1 & 2.

    The problems arrive when I want to set the widgets size before the window is shown. I have the following lines in order to try and have the figure shown in picture 3, 1/3 of the space for the first widget and 2/3 for the second one in each splitter.

    Qt Code:
    1. ui->treeSplitter->setStretchFactor(0, 1);
    2. ui->treeSplitter->setStretchFactor(1, 2);
    3.  
    4. ui->logSplitter->setStretchFactor(0, 1);
    5. ui->logSplitter->setStretchFactor(1, 2);
    6.  
    7. ui->tableSplitter->setStretchFactor(0, 1);
    8. ui->tableSplitter->setStretchFactor(1, 2);
    To copy to clipboard, switch view to plain text mode 


    Is there something I am missing? Could you point me out where the problem could be?

    Thanks in advance.

    1.png2.png3.jpg
    Last edited by godi; 28th September 2011 at 08:27.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Widget proportions in QSplitter

    http://doc.qt.nokia.com/4.7/qsplitte...tStretchFactor

    stretch is not the effective stretch factor; the effective stretch factor is calculated by taking the initial size of the widget and multiplying it with stretch.

  3. #3
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Widget proportions in QSplitter

    Thanks amleto. I forgot to say that I had some previous code indicating the same initial size for all the elements in the splitters.

    Qt Code:
    1. QList<int> sizes;
    2. sizes.append(100);
    3. sizes.append(100);
    4.  
    5. ui->treeSplitter->setSizes(sizes);
    6. ui->logSplitter->setSizes(sizes);
    7. ui->tableSplitter->setSizes(sizes);
    To copy to clipboard, switch view to plain text mode 

    Am I using the combination of "setSize" and "setStretchFactor" in a bad way? Is there any other thing I should do apart from this?

    Thanks in advance.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Widget proportions in QSplitter

    It looks like you may not have added the widgets already? Apart from that I'm out of ideas

  5. #5
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Widget proportions in QSplitter

    Hello amleto,

    The code I have shown here is in the constructor of the widget and previous to those lines I have

    Qt Code:
    1. ui->setupUi(this);
    To copy to clipboard, switch view to plain text mode 

    so the widget has been initalized and created for the splitter because they are place in the .ui file associated.

    I think the stretch factor is not properly explained in the official documentation. In fact, I have found a link where it is said that setting the stretch factor to 1 for a widget while not setting it for rest of widgets in the same QSplitter objects allows the widget with stretch factor equal to one to get any additional space that is available.

    I am very confused about the stretch factor.

Similar Threads

  1. QSplitter ignores some widget methods
    By lotek in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2010, 20:29
  2. Size proportions of widgets in QSplitter
    By Boron in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 18:25
  3. Bug in QSplitter with Qt4.5.1
    By araglin in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2009, 07:45
  4. QSplitter
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2009, 13:46
  5. New to QSplitter
    By bruccutler in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2007, 16:43

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.