I know this question was asked before in this thread but I want to add to it.

I want to render a custom widget in a QListView. The above thread shows how to do this using QStyle to paint a progress bar manually. That is a great help! But what if i want a more complex widget (with a layout, buttons, text, and an icon) instead of just a single progress bar?

The ways of doing this that I can think of are:
  1. design the widget in Designer, load my data into it and render it to a pixmap and then paint the pixmap during the QItemDelegate's paint method. The problem here is that the widget would not be interactive (can't click the buttons etc).
  2. create a widget for each item in the list. For long lists this would mean too many widgets. How would you draw a widget during QItemDelegate's paint method anyways?
  3. use QStyle's drawControl method. But how do you make it adhere to a layout? Do I need to have pixel absolute offsets for each control, this would suck because then resizing the list doesn't help. Also how to I communicate the size to the sizeHint method? This seems to be the right way to go except for the problems I mentioned.


Am I on the right track here or has anyone done this before?