Results 1 to 1 of 1

Thread: Strange QGridLayout behaviour

  1. #1
    Join Date
    Oct 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Strange QGridLayout behaviour

    Hi!

    Here is an example code with a simple QGridLayout, which contains 3 QLabels and 2 QSpinBoxes. When I increase the window's size, the two bottom rows stay at the bottom and it increases the space between them and the top QLabel.

    Can someone explain why and how to obtain equally spaced rows.

    I have tried using setRowStretch and it works, but then, the other Widgets which are on top of this QGridLayout in my App don't stretch at all when resizing the window.

    Thanks in advance,
    M.

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char** argv)
    4. {
    5. QApplication app(argc, argv);
    6.  
    7.  
    8. QGridLayout* gb3fr2gridlayout=new QGridLayout;
    9. QLabel* gb3label4=new QLabel("Number of samples :");
    10. QLabel* gb3label5=new QLabel("Distance :");
    11. QLabel* gb3label6=new QLabel("Time :");
    12. QSpinBox* gb3sb1=new QSpinBox;
    13. gb3sb1->setDisabled(true);
    14. QSpinBox* gb3sb2=new QSpinBox;
    15. gb3sb2->setDisabled(true);
    16. gb3fr2gridlayout->addWidget(gb3label4, 0, 0, 1, 2);
    17. gb3fr2gridlayout->addWidget(gb3label5, 1, 0);
    18. gb3fr2gridlayout->addWidget(gb3label6, 2, 0);
    19. gb3fr2gridlayout->addWidget(gb3sb1, 1, 1);
    20. gb3fr2gridlayout->addWidget(gb3sb2, 2, 1);
    21.  
    22. w.setLayout(gb3fr2gridlayout);
    23. w.show();
    24.  
    25. return app.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. Strange xml behaviour when opening the file.
    By cbarmpar in forum Qt Programming
    Replies: 5
    Last Post: 28th September 2008, 20:44
  2. qinputdialog strange behaviour
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2008, 19:29
  3. very strange behaviour
    By regix in forum Qt Programming
    Replies: 23
    Last Post: 20th July 2006, 17:38
  4. Replies: 1
    Last Post: 26th February 2006, 05:52
  5. [Qt 4.1] Strange behaviour with QTableView
    By fane in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 06: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.