Height of editor in QItemDelegate

1.9k Views Asked by At

I have QListView with custom implementation of QItemDelegate. MyItemDelegate reimplements createEditor() to show custom widget. Size of widget is dependant on content. By default, each row height is about 20px (one row), but my editor has bigger height. I was trying to override QItemDelegate::sizeHint() method, but is doesn't contains reference to editor, so I couldn't calculate correct size.

How can I make QListView resize rows to actual size of editor?

1

There are 1 best solutions below

11
On

You should emit layoutChanged after creating an editor, if you could not override sizeHint correctly. But it should be enough to override sizeHint.