1
votes

I have an application, written in PyQt. I use QTableWidget-based class for grids. All is Ok, except that in some cases (long text data in cells) item size is determined wrong and some clipping occures. Quick'n'dirty hack is to override delegate's sizeHint() function, but there are thousands of items in the table, and I think, that calling python (!) function for every and each cell of the huge table is bad. Moreover, let's say, 5px borders for all (not only those, badly rendered) items isn't pretty.

Wrong item size

Can someone provide more abequate way to fix it?

2
I can't reproduce this. Please provide a simple example script that demonstrates the problem. (It might also to useful to say what version of Qt are you using - I'm using Qt-4.7.4).ekhumoro
@ekhumoro I use version 4.7.4 too, and I solved this issue trying to provide a short example for you:) My custom delegate was inherited from QItemDelegate, default sizeHint of witch is working wrong, at least in Windows XP and Windows 7, Qt 4.7.4 and some recent Qt versions.Maxim Popravko
@ekhumoro QStyledItemDelegate is working fine.Maxim Popravko

2 Answers

1
votes

I supposed to use QStyledItemDelegate to inherit my custom delegate of. With QStyledItemDelegate items are rendered fine!

0
votes

You should be able to call QTableWidget().verticalHeader().setDefaultSectionSize(rowheight) to set the base size for all table rows.