How to resize QListView row to index widget size
- 
I have custom model( ListModel), which containsAbstractModel*. From theAbstractModelare inherited 3 models :User,GroupandChat. Each of the models have own view (***View). I need to set my model(ListModel) and set for each item(index forQListView) own view. But when I set view (QListView::setIndexWidget) row height remains default.How to make the height of the row equal to the height of its view(views can resize dynamically)? QListViewhavesizeHintForRowmethod, but it never calls.
 From Qt docs: "Note that to control the height of a row, you must reimplement theQAbstractItemDelegate::sizeHint()function". But I can't get access to index widget from delegate.What I can do? 
- 
I have custom model( ListModel), which containsAbstractModel*. From theAbstractModelare inherited 3 models :User,GroupandChat. Each of the models have own view (***View). I need to set my model(ListModel) and set for each item(index forQListView) own view. But when I set view (QListView::setIndexWidget) row height remains default.How to make the height of the row equal to the height of its view(views can resize dynamically)? QListViewhavesizeHintForRowmethod, but it never calls.
 From Qt docs: "Note that to control the height of a row, you must reimplement theQAbstractItemDelegate::sizeHint()function". But I can't get access to index widget from delegate.What I can do? @sm4ll-3gg said in How to resize QListView row to index widget size: QAbstractItemDelegate::sizeHint() function". But I can't get access to index widget from delegate. The index is the second argument of sizehint... http://doc.qt.io/qt-5/qabstractitemdelegate.html#sizeHint 
- 
@sm4ll-3gg said in How to resize QListView row to index widget size: QAbstractItemDelegate::sizeHint() function". But I can't get access to index widget from delegate. The index is the second argument of sizehint... http://doc.qt.io/qt-5/qabstractitemdelegate.html#sizeHint 
- 
Nope, the delegate replaces the indexWidgetcompletely.What kind of widgets are you using? are they simple Qt widgets or are they composite? @VRonin I'm using composite custom widgets. Yep, you right, delegate replaces indexWidget, but I don't understand how show my custom widget for display, not for edit.
 I.e., I need to all widgets are always visible, not only when edit requestedActually, I do not need editing at all. I need only show widgets and use them Please tell me how this can be done, if you know. Because I google it for 3 days. And I didn't find the right answer. The createEditormethod shows the widget only for editing.
- 
It's not a trivial task. If your model is not huge you could use something like this: https://pastebin.com/XrppLZ3m but, in general, you'd have to manually handle the painting 
- 
It's not a trivial task. If your model is not huge you could use something like this: https://pastebin.com/XrppLZ3m but, in general, you'd have to manually handle the painting @VRonin Ty, it's works, what I should read to better understand Model / View / Delegate programming? I read all the documentaition on qt.io about this theme, but I did not see anything even remotely resembling such an approach. P.S. It is normal to set new delegate for each item if I need to show heterogeneous data in list? 
- 
@VRonin Ty, it's works, what I should read to better understand Model / View / Delegate programming? I read all the documentaition on qt.io about this theme, but I did not see anything even remotely resembling such an approach. P.S. It is normal to set new delegate for each item if I need to show heterogeneous data in list? @sm4ll-3gg said in How to resize QListView row to index widget size: what I should read to better understand Model / View / Delegate programming? Basically everything I know comes from Advanced Qt Prgramming: Creating Great Software with C++ and Qt4 It is normal to set new delegate for each item if I need to show heterogeneous data in list? No. What I would do is create a QStackedWidget with the possible combinations, use that as base and display the correct page based on the data in the index 
