PDA

View Full Version : Tree View with Icons/primitives



dosto.walla
3rd October 2008, 11:07
Hello,


I am reading a database and would like to view the some of the contents of the database in tree view with items represented as icons/primitives(colored circles,rectangles) along with the text.

Could anyone provide some reference on that issue?


Thanks
Sajjad

DIMEDROLL
3rd October 2008, 11:23
Hi
Use QTreeView for displaying you data
QStandardItemModel for creating a tree
QStandardItem as an item in your tree, QStandardItem has a setIcon() method

spirit
3rd October 2008, 11:29
do you mean how to set an icon in QTreeView or QTreeWidget?
for QTreeView use this method


bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )

example


...
model()->setData(index, QIcon(fileName), Qt::DecorationRole);
...

for QTreeWidget


...
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setIcon(column, QIcon(fileName));
...