Custom list widget
-
Hi @Robey-Mardon and Welcome,
With that amount of customization its better to go withQListView
with custom delegate. You can use QStyledItemDelegate and reimplement paint method to draw text or pixmaps using QPainter's drawText and drawPixmap. Explore more functions for QPainter.
Now to draw controls like buttons and progressbar use classes like QStyleOptionButton and QStyleOptionProgressBar inherited from QStyleOption.More about Model/View Programming in Qt is here .
-
Hi,
I have another perhaps easyer solution that I have already used in one software. You use a QTableWidget with one column instead of a QListWidget, and you create a class that derivate from QTableWidgetItem and of Qwidget :#define WType ((QTableWidgetItem::UserType)+200) class TableWidgetItem : public QTableWidgetItem,public QWidget { public: TableWidgetItem(QWidget * parent = 0, Qt::WindowFlags f = 0,int type=WType); ...
as this class derivate from Qwidget you can add what you want in this class..it runs well.and you insert objects of this class in you QTablewidget.
-
@stephane78 Well in that case why
QTableWidget
andQTableWidgetItem
? UseQListWidget
andQListWidgetItem
. Using custom delegates for large customization is more flexible. -
@p3c0
you are right it's better to use custom delegates like you say.
I am not sure my solution runs with QListWidget but it is ok too with QTablewidget.