It doesn't seem possible to apply a delegate on a specific number of cells.
The delegate is free to distinguish between cells any way it sees fit. For example, do not paint the top level cells:
// something like
{
if (!index.isvalid())
return;
const QModelIndex leftmostSibling
= index.
sibling(index.
row(),
0);
if (leftmostSibling.parent().isValid()) {
// not on top level of tree
// paint stuff
}
else {
// default behaviour
QStyledItemDelegate::paint(painter, option, index);
}
}
// something like
void MyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (!index.isvalid())
return;
const QModelIndex leftmostSibling = index.sibling(index.row(), 0);
if (leftmostSibling.parent().isValid()) {
// not on top level of tree
// paint stuff
}
else {
// default behaviour
QStyledItemDelegate::paint(painter, option, index);
}
}
To copy to clipboard, switch view to plain text mode
You can look at the source for the "Property Editor" of QtCreator, so there should not be a huge mystery.
There's also an independent implementation at http://qt-apps.org/content/show.php/...?content=68684 but I cannot vouch for its completeness, robustness etc.
Bookmarks