Results 1 to 4 of 4

Thread: Qlist geometry interference with GridLayout in QT Designer

  1. #1
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Qlist geometry interference with GridLayout in QT Designer

    Hi all,

    I try to design a dialog with QtDesigner. Inside a Group box i want the following layout

    label... Spinbox1 Spinbox1
    ####
    #....#
    #....# . Lineedit
    #....#
    #....#
    ####


    where ### is the listbox.

    every time I try to use a grid layout the size of the list box grows to much bigger size than I need. Even if i set the sizePolicy to fixed to Minimum or every other value

    How can I prevent this nasty behaviour ?

    Thanks an have a nice day

    dexli

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,713
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qlist geometry interference with GridLayout in QT Designer

    setting maximum width must work.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,640
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qlist geometry interference with GridLayout in QT Designer

    Or you can use the stretch parameter to QBoxLayout::addWidget() to apportion the available space in a known ratio:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class MainWindow: public QMainWindow {
    5. Q_OBJECT
    6. public:
    7. MainWindow(QWidget *p = 0): QMainWindow(p) {
    8. QWidget *central = new QWidget(this);
    9. QListView *list = new QListView(this);
    10. QLineEdit *edit = new QLineEdit(this);
    11.  
    12. QHBoxLayout *layout = new QHBoxLayout(central);
    13. layout->addWidget(list, 1); // allocate 1 unit to this
    14. layout->addWidget(edit, 2); // and 2 units to this
    15.  
    16. central->setLayout(layout);
    17. setCentralWidget(central);
    18. }
    19. public slots:
    20. private:
    21. };
    22.  
    23. int main(int argc, char *argv[])
    24. {
    25. QApplication app(argc, argv);
    26.  
    27. MainWindow m;
    28. m.show();
    29. return app.exec();
    30. }
    31. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    How you tweak the layout depends on exactly what behaviour you want.

  4. #4
    Join Date
    Mar 2011
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qlist geometry interference with GridLayout in QT Designer

    Thanks for the hints.
    I decide to omit the layout around this widget. This was the easiest way, because the other solutions seem to be a kind of hacking.

Similar Threads

  1. Visual studio 2010 interference
    By The physicist in forum Installation and Deployment
    Replies: 3
    Last Post: 14th January 2011, 09:43
  2. Replies: 4
    Last Post: 20th August 2010, 13:54
  3. Widget layout in GridLayout
    By Dato0011 in forum Qt Programming
    Replies: 8
    Last Post: 7th December 2009, 09:26
  4. QMdiArea with Gridlayout
    By ericV in forum Qt Programming
    Replies: 0
    Last Post: 14th September 2009, 11:26
  5. does gridlayout really lay out?
    By illuzioner in forum Newbie
    Replies: 2
    Last Post: 26th February 2006, 00:57

Tags for this Thread

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.