Results 1 to 3 of 3

Thread: Problem with QSplitter

  1. #1
    Join Date
    Jun 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with QSplitter

    Hi all,

    I have a mainwindow with multiple widgets and a horizontal layout.
    I tried to add a QSplitter to be able to resize them on runtime.

    Qt Code:
    1. QSplitter splitter = new QSplitter;
    2. splitter->setChildrenCollapsible(false);
    3. splitter->setOrientation(Qt::Horizontal);
    4. splitter->addWidget(ui->listWidget);
    5. splitter->addWidget(ui->widget);
    6. splitter->addWidget(ui->pushButton);
    7. splitter->addWidget(ui->scrollArea);
    8. splitter->show();
    To copy to clipboard, switch view to plain text mode 

    It works fine, except that the mentioned widgets 'pop out' of the mainwindow, leaving an empty mainwindow with only the status and menubar behind.
    Take a look:



    How can I keep the widgets inside the mainwindow?
    Thanks for the support.

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

    Default Re: Problem with QSplitter

    Widgets with no parent will be a window. Hence your splitter will be in its own window. Just make it the central widget in the mainwindow http://qt-project.org/doc/qt-4.8/qma...tCentralWidget.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jun 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QSplitter

    Works like a charm, thank you!

Similar Threads

  1. qsplitter
    By marc2050 in forum Newbie
    Replies: 3
    Last Post: 31st May 2011, 16:06
  2. Bug in QSplitter with Qt4.5.1
    By araglin in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2009, 07:45
  3. QSplitter
    By weixj2003ld in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2009, 13:46
  4. New to QSplitter
    By bruccutler in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2007, 16:43
  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.