PDA

View Full Version : Forcing equal row heights in QTableWidget



wssddc
31st October 2009, 22:56
I'd like the height of all rows in a QTableWidget to change when any row is resized. I can use verticalHeader()->setDefaultSectionSize() to set the row height, but how do I detect when I need to do this? There's a resizeEvent that I use to adjust column widths when the whole table is resized, but there doesn't seem to be an event triggered by resizing rows. Am I missing something obvious?

I'm using the 4.6.0 beta under Windows with MinGW.

Lykurg
1st November 2009, 07:26
Hi,

fetch the QHeaderView::sectionResized() signal and then set the corresponding hight for all rows.

wssddc
2nd November 2009, 01:16
Thanks, I'm much closer to getting it to work now. The first complication is that whether I set the height for each row or do them all at once with setDefaultSectionSize, a sectionResized signal is sent for each row. I don't get an infinite loop, so I guess setting the height to the value it already has doesn't generate a signal.

I can avoid the extra signals by blocking them or by disconnecting. If I block signals from the verticalHeader, display of both the header and the table tend to get messed up, and update or repaint from within the signal handler doesn't help. (Manual scrolling fixes it.) If I disconnect from the signal, only the vertical header display is messed up.

If the row I'm resizing is the first one in the table, things look good. But if it's a later row, or worse if the table has been scrolled, the row being resized moves, perhaps out of the viewport.