Hello,
im using a QTreeView with a QAbstractItemModel.
Now i like to show a Icon for each Level, like QDirModel does.
level 1 shows icon1.png
level 2 shows icon2.png
How can i do that?
Hello,
im using a QTreeView with a QAbstractItemModel.
Now i like to show a Icon for each Level, like QDirModel does.
level 1 shows icon1.png
level 2 shows icon2.png
How can i do that?
use
bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
or
bool QAbstractItemModel::setItemData ( const QModelIndex & index, const QMap<int, QVariant> & roles ) [virtual]
Mithin
www.mithin.in
Thank you for the tip! i was just searching for icons, didnt thought of roles.
But how can i use it? Do you have an short example code?
Just the thing with showing icons, i dont need to change data in the model, mine is readonly.
Return the pixmap in
for role Qt::DecorationRole.Qt Code:
To copy to clipboard, switch view to plain text mode
more or less like this:
Qt Code:
{ if (role == Qt::DecorationRole) { } ... }To copy to clipboard, switch view to plain text mode
J-P Nurmi
yippih.. thats is!! Thank you so much!!
You saved me many hours of searching, reading my book and trying!
Bookmarks