[Qt-interest] decoration role for the tree model subclass

ami guru dosto.walla at gmail.com
Tue Dec 16 23:52:27 CET 2008


Hello forum,

I have derived a class from AbstractItemModel and implemented a tree model.

I want to associate an icon for each item in the model. And that icon is
draggable to
the scene.


I need some hint to create icon for each item of the  tree model.

the data() has been reimplemented as guided in the manual , did not say
anything about
loading icon for the item at run time.

***************************************'

QVariant H3DTreeModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (role != Qt::DisplayRole)
        return QVariant();

    H3DTreeItem *item = static_cast<H3DTreeItem*>(index.internalPointer());


    //qDebug() << "Data at the model" << endl;

    return item->data(index.column());
}




***************************************'


How to generate the icon in the above code and assign role for that


Any hint?


Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081216/00f62ed1/attachment.html 


More information about the Qt-interest-old mailing list