PDA

View Full Version : Customize drop indicator in QTreeView



novakk
26th October 2010, 23:23
Hello,

I am trying to customise the drop indicator in QTreeView with no success. I've browsed the web, but found no info.
Can anyone guide me where to start?

novakk

hwerglmir
27th November 2010, 07:05
Hi

look at QProxyStyle.

Here's an example I've made for the DropIndicator.


class MyProxyStyle : public QProxyStyle
{
public:
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
if(element == QStyle::PE_IndicatorItemViewItemDrop)
{
painter->setRenderHint(QPainter::Antialiasing, true);

QPalette palette;
//QColor(90,108,217)
QColor c(palette.highlightedText().color());
QPen pen(c);
pen.setWidth(2);
c.setAlpha(50);
QBrush brush(c);

painter->setPen(pen);
painter->setBrush(brush);
if(option->rect.height() == 0)
{
painter->drawEllipse(option->rect.topLeft(), 3, 3);
painter->drawLine(QPoint(option->rect.topLeft().x()+3, option->rect.topLeft().y()), option->rect.topRight());
} else {
painter->drawRoundedRect(option->rect, 5, 5);
}
} else {
QProxyStyle::drawPrimitive(element, option, painter, widget);
}


}
};

novakk
28th November 2010, 22:03
Thank you for your help!