Results 1 to 4 of 4

Thread: How do I squash a widget in a grid layout down to the bottom to its minimum size?

  1. #1
    Join Date
    Apr 2015
    Posts
    11
    Qt products
    Qt5
    Platforms
    Windows

    Red face How do I squash a widget in a grid layout down to the bottom to its minimum size?

    I have a widget I made in Qt Designer and a QGraphicsView. I'd like:

    [QGraphicsView]
    [ " ]
    [ " ]
    [ " ]
    [ " ]
    [ " ]
    [MyCustomWidget]

    Instead, the layout is coming out like this:

    [QGraphicsView]
    [MyCustomWidget]

    ie. 50 /50 split of vertical space. I've played around with the row/column span versions of gridLayout.addWidget(), and they didn't make any difference.

    Thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How do I squash a widget in a grid layout down to the bottom to its minimum size?

    The layout allocates the available space between the widgets that want it. If you place nothing in rows 1-5 of the grid then there is nothing to occupy space there, so the two actual widgets get the space. You have a range of options: set a maximum height on the custom widget, setRowStretch() to 1 for all rows except the last which gets 0, put (expanding) vertical spacers in the empty grid rows. What effect are you trying to achieve with the empty grid squares?

  3. #3
    Join Date
    Apr 2015
    Posts
    11
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How do I squash a widget in a grid layout down to the bottom to its minimum size?

    The "empty grid rows" will not be empty they will be occupied by the QGraphicsView. I want a maximized QGraphicsView and a minimized lower custom widget.


    Added after 13 minutes:


    Setting the size policy of either subwidget does nothing. Setting the row stretch or setting the rowSpan do nothing either.
    Last edited by enjoysmath; 10th August 2015 at 20:00.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How do I squash a widget in a grid layout down to the bottom to its minimum size?

    So you have two widgets?
    Why use a grid layout at all?
    Sounds like a QVBoxLayout use case to me.

    Cheers,
    _

Similar Threads

  1. QMainWindow central widget minimum size
    By dima in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2010, 08:24
  2. Replies: 2
    Last Post: 23rd March 2009, 18:26
  3. Minimum QGroupBox size
    By klnusbaum in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2008, 18:22
  4. Qt Layout engine not respecting minimum size?
    By Mike in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2007, 14:27
  5. How do I move a widget inside a grid Layout
    By barnabyr in forum Newbie
    Replies: 1
    Last Post: 9th May 2006, 00:23

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.