[Qt-interest] How Can I use ListView to show QIcons ?
Alessandro Portale
Alessandro.Portale at trolltech.com
Wed Jun 24 11:24:24 CEST 2009
Kermit Mei schrieb:
> On Wed, 2009-06-24 at 10:36 +0200, Alessandro Portale wrote:
>> Kermit Mei schrieb:
>>> QVariant ListModel::data(const QModelIndex &index, int role) const {
>>> if(index.isValid())
>>> return QVariant(icons.at(index.column()));
>>> else
>>> return QVariant();
>>> }
>> You need to consider the data role. Only return an icon, when role ==
>> Qt::DecorationRole.
>>
>> Alessandro
>
> Yes,I see. Thanks you all to help me.
>
> But, I always can't understand the thinking of the keyword 'role' here.
> And I can't understand it in the other model.
> Can you give me some link about it?
>
> Thank you, very much!
>
> Kermit
For getting an overview of Model/View programming with Qt, this is a
great place to start
http://doc.qtsoftware.com/latest/model-view-programming.html
Here is a description of the role concept:
http://doc.qtsoftware.com/latest/model-view-model.html#item-roles
Alessandro
More information about the Qt-interest-old
mailing list