PDA

View Full Version : [Qt4] QTableWidget set size automatically to minimum



Boy
23rd June 2008, 14:21
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?

lyuts
24th June 2008, 11:18
Use setSizePolicy( QSizePolicy::Policy, QSizePolicy::Policy) for width and for height.

One thing more, I would not recommend you use QSizePolicy::Fixed.