QTreeView使用点点滴滴

QTreeView比较复杂,在这里记下所有用到的操作:

-----------------------------------------------------------------------------

如何给QTreeView的节点显示图标
要显示节点图标,就在重写模型的时候在DecorationRole角色时返回要显示的图标就可以了

    Node *node = nodeFromIndex(index);
    if (role == Qt::DecorationRole){
        switch(node->item){
            case Node::    Root:
                return QIcon(":/images/ras.ico");
            case Node::Downloading:
                return QIcon(":/images/Download.png");
            case Node::Downloaded:
                return QIcon(":/images/Misc-Stuff.png");
            case Node::Daily:
                return QIcon(":/images/Database.png");
            case Node::Timespace:
                return QIcon(":/images/Software.ico");
        }
    }

 -----------------------------------------------------------------------------

带图标,还可双击

http://blog.csdn.net/pigautumn/article/details/9036839

使用图标:

http://blog.csdn.net/vah101/article/details/6190978

设置行高:

http://blog.csdn.net/lutx/article/details/6641353

posted @ 2014-10-09 15:27  findumars  Views(4231)  Comments(0Edit  收藏  举报