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