PDA

View Full Version : How to use Q_Property to customize items in a QListView with a QStyledItemDelegate



manuelschneid3r
15th April 2015, 18:29
I have custom listview items in my QListView, which are drawed by a QStyledItemDelegate. They contain two lines of text which should be both customizable with stylesheets. The first is set by
#list {font: 26px "Ubuntu";}, which works fine. But the second should be stylable as well. Qt [mentions][1] that any designable Q_PROPERTY can be set by the stylesheet, but I wonder where to define and how to access these properties from the QStyledItemDelegate::paint method.

[1]: http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html#setting-qobject-properties

wysota
20th April 2015, 08:52
Where would that property be defined? Items do not have properties. You should rather build a custom delegate and use model data to render what and how you want.