Results 1 to 2 of 2

Thread: [Qt4] QTableWidget set size automatically to minimum

  1. #1
    Join Date
    Mar 2008
    Posts
    25
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default [Qt4] QTableWidget set size automatically to minimum

    I have a QTableWidget. I have the size for the width set to 600. But runtime I want to determine the height of it.

    I don't know how many rows the table will have until it is constructed at runtime. I have been playing with adjustSize(), I've set the minimum size 600 x 20 (too small, I know), number of rows have been set (just for trying it out) in the Qt Designer on 2. But it just uses the sizeHint() and this one returns 256x256.

    Now I found out that you need a layout to get it to take notice of the minimum size. So I just took a spacer and made a layout of it. this now works for the width (set sizepolicy for this on fixed) but the height is ignored.

    What am I doing wrong? Anyone experience on this?

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [Qt4] QTableWidget set size automatically to minimum

    Use setSizePolicy( QSizePolicy::Policy, QSizePolicy::Policy) for width and for height.

    One thing more, I would not recommend you use QSizePolicy::Fixed.
    I'm a rebel in the S.D.G.

Similar Threads

  1. Qt Layout engine not respecting minimum size?
    By Mike in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2007, 13:27

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.