Treeview with grid lines
General and Desktop
2
Posts
2
Posters
5.9k
Views
1
Watching
-
Hi
You can create a delegate for example :-.h
@class TreeViewDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit TreeViewDelegate(QObject *parent = 0);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;};@
.cpp
@TreeViewDelegate::TreeViewDelegate(QObject *parent) :
QStyledItemDelegate(parent)
{}
void TreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter,option,index);QPen pen; pen.setWidth(1); painter->setPen(pen); painter->drawRect(option.rect);
}@
then you can set the the delegate to the treeView
@ui->treeView->setItemDelagate(treeDelegate);@