PDA

View Full Version : QTableWidget column and row sizes



Arthur
26th January 2006, 16:41
Hello,

Currently I have the following question. How could I set:

- Default row height of a QTableWidget row
- Default column width of a QTableWidget column

I know you can do this by implementing sizeHint in a QItemDelegate, and use resize functions, but since I have douzens of rows and columns I want a decent default size.

On the 'old' Qt forum there was a post by someone who provided a 'patch', for the row height (defaultSectionSize method and sectionSizeFromContents), but that patch doesn't work for some reason. I cannot post on that forum anymore, so I would appreciate it if some Qt guru could tell me how to implement this.

Greets,
Arthur

krawek
26th January 2006, 16:48
Hi,

use QHeaderView::resizeSection

Arthur
26th January 2006, 17:05
Thank you for your reply.

The problem is that I absolutely don't want to resize, since this is way to slow. I want to change the default size.

Arthur

Opilki_Inside
26th January 2006, 20:22
resizeSection is a better way to resize hight of all your rows...
it works fast, if you use setUpdatesEnabled...

the default row height you can't set at all.

here is an example... it's wrote on Qt3, but i think it will work on Qt4 similar...


verticalHeader()->setUpdatesEnabled(FALSE);

for (unsigned int i = 0; i < numRows(); i++)
verticalHeader()->resizeSection(i, rowHeight);

verticalHeader()->setUpdatesEnabled(TRUE);

Arthur
27th January 2006, 12:03
Ok thanks, that helps a lot...