It can looks like:
1) first prepare class:
{
Q_OBJECT
public:
{
}
{
s.setHeight(row_height);
return s;
}
void setRowHeight(const unsigned char height)
{
row_height = height;
}
protected:
unsigned char row_height;
};
class CTreeDelegate : public QItemDelegate
{
Q_OBJECT
public:
CTreeDelegate(QObject *parent) : QItemDelegate(parent)
{
}
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize s = QItemDelegate::sizeHint(option, index);
s.setHeight(row_height);
return s;
}
void setRowHeight(const unsigned char height)
{
row_height = height;
}
protected:
unsigned char row_height;
};
To copy to clipboard, switch view to plain text mode
or if you wan't change height at run apps:
{
Q_OBJECT
public:
{
}
{
s.setHeight(row_height);
return s;
}
protected:
const unsigned char row_height;
};
class CTreeDelegate : public QItemDelegate
{
Q_OBJECT
public:
CTreeDelegate(QObject *parent, unsigned char height) : QItemDelegate(parent), row_height(height)
{
}
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize s = QItemDelegate::sizeHint(option, index);
s.setHeight(row_height);
return s;
}
protected:
const unsigned char row_height;
};
To copy to clipboard, switch view to plain text mode
2) and add the class to your tree:
CTreeDelegate *delegate = new CTreeDelegate(this);
delegate->setRowHeight(25); // for example 25
tree->setItemDelegate(delegate);
CTreeDelegate *delegate = new CTreeDelegate(this);
delegate->setRowHeight(25); // for example 25
QTreeWidget *tree = new QTreeWidget(this));
tree->setItemDelegate(delegate);
To copy to clipboard, switch view to plain text mode
Bookmarks