Tree View with Icons/primitives
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
Re: Tree View with Icons/primitives
Hi
Use QTreeView for displaying you data
QStandardItemModel for creating a tree
QStandardItem as an item in your tree, QStandardItem has a setIcon() method
Re: Tree View with Icons/primitives
do you mean how to set an icon in QTreeView or QTreeWidget?
for QTreeView use this method
Quote:
bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
example
Code:
...
model()->setData
(index,
QIcon(fileName
), Qt
::DecorationRole);
...
for QTreeWidget
Code:
...
item
->setIcon
(column,
QIcon(fileName
));
...