[Development] Deprecation of Qt Quick Controls 1

Kevin Kofler kevin.kofler at chello.at
Thu Feb 8 04:27:21 CET 2018


NIkolai Marchenko wrote:
> even stuff like that?
> https://imgur.com/a/tTFeO

Maybe try using QListWidget::setItemWidget? That should even let you assign 
some widget layed out in Qt Designer.

Also FYI, since QListWidget is a subclass of QListView, you can actually 
also use a QAbstractItemDelegate with a QListWidget (hint: 
QListWidget::itemFromIndex does wonders to actually find the QListWidgetItem 
in the delegate), even though the documentation omits that detail or even 
tries to imply otherwise. (And the same goes for tree widgets, just 
s/List/Tree/g in the previous sentence.) Kompare actually declares a 
subclass of QTreeWidgetItem with a virtual paintCell method, subclass which 
is the superclass of all the concrete item subclasses, which 
implement/override the paintCell method, and then sets a (subclassed) 
QStyledItemDelegate that just calls that virtual paintCell method when the 
tree widget asks it (the delegate) to paint the item. (For a bit of history: 
The virtual paintCell method in the item was how things worked in Qt 3 out 
of the box. It took me just a few lines of item delegate code to emulate 
that way of working in Qt 4 and 5, and I think this can be a convenient 
trick even in new code.)

        Kevin Kofler




More information about the Development mailing list