Results 1 to 3 of 3

Thread: QVBoxLayout to center

  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default QVBoxLayout to center

    when i use the code below, Qt puts labels on the right side.
    How can i put labels centered in the line?

    Qt Code:
    1. myproject::myproject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
    2. {
    3. ui.setupUi(this);
    4.  
    5. QVBoxLayout *mainlayout = new QVBoxLayout;
    6. QLabel *label1= new QLabel("aaa");
    7. QLabel *label2= new QLabel("bbb");
    8. QLabel *label3= new QLabel("cccc");
    9. QLabel *label4= new QLabel("ddd");
    10. mainlayout->addWidget(label1);
    11. mainlayout->addWidget(label2);
    12. mainlayout->addWidget(label3);
    13. mainlayout->addWidget(label4);
    14. ui.centralWidget->setLayout(mainlayout);
    15.  
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  3. The following user says thank you to tbscope for this useful post:

    seltra (7th October 2010)

  4. #3
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QVBoxLayout to center

    thank you tbscope. it worked.

Similar Threads

  1. QHBoxLayout & QVBoxLayout
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2010, 14:13
  2. QVBoxLayout and QHBoxLayout problem
    By fmariusd in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2009, 20:58
  3. Inconsistent behaviour of QVBoxLayout
    By spraff in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2008, 18:36
  4. QScrollView with a QVboxlayout
    By rishid in forum Newbie
    Replies: 1
    Last Post: 18th January 2008, 16:14
  5. Disappearing widgets in QVBoxLayout
    By torleifs in forum Newbie
    Replies: 1
    Last Post: 24th October 2007, 13:17

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.