Results 1 to 4 of 4

Thread: initial size of widgets in a QSplitter

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default initial size of widgets in a QSplitter

    Hi,
    recently someone on freenode asked how to set the initial height of three Text Edits inside a QSplitter with a vertical orientation. I tried to help him but failed miserably . It was possible to set the height if you used setMaximumHeight but he wanted the size to be adjustable by the user (otherwise using a QSplitter wouldn't have made sense anyway) which isa legitimate and reasonable request after all. The top and the bottom text edits shall take up twice the height of the current font. The text edit in between should get the rest.

    I tried this and it didn't work
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char** argv)
    4. {
    5. QApplication app(argc, argv);
    6.  
    7. QSplitter* splitter = new QSplitter(Qt::Vertical);
    8. for (int i = 0; i < 3; ++i) {
    9. QTextEdit* te = new QTextEdit("Text Edit nr. " + QString::number(i));
    10. splitter->addWidget(te);
    11. if (i % 2 == 0)
    12. te->resize(te->sizeHint().width(), te->fontMetrics().height() * 2);
    13. }
    14.  
    15. mw.setCentralWidget(splitter);
    16. mw.show();
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 
    Any Ideas?

    Thanks in advance
    Last edited by momesana; 13th December 2009 at 01:20.

Similar Threads

  1. Replies: 4
    Last Post: 11th July 2010, 09:47
  2. Adjust the initial size of a QTextEdit in a layout
    By hecinho in forum Qt Programming
    Replies: 0
    Last Post: 26th November 2009, 15:58
  3. resizing widgets depending on a main widget size
    By luf in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2009, 16:13
  4. Size proportions of widgets in QSplitter
    By Boron in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 18:25
  5. Replies: 1
    Last Post: 27th March 2008, 15:10

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.