qt-interest@trolltech.com
[Top] [All Lists]

Re: QTreeView item icons

Subject: Re: QTreeView item icons
From: Bernd Brandstetter
Date: Fri, 5 Aug 2005 18:20:00 +0200
On Friday 05 August 2005 15:57, Nick Arini wrote:
> Hi,
>
> can anyone tell me how to add an icon to a QTreeView using the
> model/view architecture.
>
> I have tried using model->setData(index, QIcon("image.png"),
> Qt::DecorationRole) and while this does not cause compiler errors it
> does not display the icon.
>
> I have modified the simpletreemodel example. so model here is a subclass
> of QAbstractItemModel.
>
> Thanks for any pointers.
>
> Nick

Have you reimplemented QAbstractItemModel::setData() as the documentation 
suggests and also adapted TreeModel::data() to return the icon? (The 
original implementation in the SimpleTreeModel example does only return 
QVariant() for Qt::DecorationRole).

Bernd

<Prev in Thread] Current Thread [Next in Thread>