PDA

View Full Version : Creating gaps between QTreeWidgetItems



ChiliPalmer
25th September 2009, 14:49
Hi there,

I'm working on a quite individual version of QTreeWidget. Certain items have certain looks, sizes and gaps between them.
I reimplemented QSyteldItemDelegate for the looks, and so far I also use it to create the gaps by adjusting the size of the item via my delegates sizeHint() to fit what my paint() implementation paints plus the gap.
That kind of works, but doesn't look good as the branches stop where the gaps begin and so on.

Is there any way to give a QTreeWidgetItem a top- and bottom-spacing, so there actually is a gap between the items?

aamer4yu
25th September 2009, 20:04
is there any subsection for drawing text ??
may be a proper combination of text rect, and item rect will help you achieve what you want.

drhex
26th September 2009, 21:07
Have you tried calling setItemDelegate() on your QTreeWidget to your own subclassed ItemDelegate which has a method like


QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
QSize mysize(QItemDelegate::sizeHint(option, index));
mysize.setHeight( /* your own height */ );
return mysize;
}

ChiliPalmer
26th September 2009, 23:39
To quote myself:

I reimplemented QSyteldItemDelegate for the looks, and so far I also use it to create the gaps by adjusting the size of the item via my delegates sizeHint() to fit what my paint() implementation paints plus the gap.
That kind of works, but doesn't look good as the branches stop where the gaps begin and so on.

;)

drhex
27th September 2009, 17:03
Alright, I ought to read more than the last sentence :o

But if you can control the height and have your own paint(), then surely you can make all the pixels look the way you want them to? Could you perhaps provide a drawing of what you get vs what you'd like instead?