Results 1 to 3 of 3

Thread: Customize drop indicator in QTreeView

  1. #1
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Customize drop indicator in QTreeView

    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

  2. #2
    Join Date
    Jan 2008
    Location
    Forstinning, Germany
    Posts
    10
    Thanked 7 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Customize drop indicator in QTreeView

    Hi

    look at QProxyStyle.

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

    Qt Code:
    1. class MyProxyStyle : public QProxyStyle
    2. {
    3. public:
    4. void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
    5. {
    6. if(element == QStyle::PE_IndicatorItemViewItemDrop)
    7. {
    8. painter->setRenderHint(QPainter::Antialiasing, true);
    9.  
    10. QPalette palette;
    11. //QColor(90,108,217)
    12. QColor c(palette.highlightedText().color());
    13. QPen pen(c);
    14. pen.setWidth(2);
    15. c.setAlpha(50);
    16. QBrush brush(c);
    17.  
    18. painter->setPen(pen);
    19. painter->setBrush(brush);
    20. if(option->rect.height() == 0)
    21. {
    22. painter->drawEllipse(option->rect.topLeft(), 3, 3);
    23. painter->drawLine(QPoint(option->rect.topLeft().x()+3, option->rect.topLeft().y()), option->rect.topRight());
    24. } else {
    25. painter->drawRoundedRect(option->rect, 5, 5);
    26. }
    27. } else {
    28. QProxyStyle::drawPrimitive(element, option, painter, widget);
    29. }
    30.  
    31.  
    32. }
    33. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Customize drop indicator in QTreeView

    Thank you for your help!

Similar Threads

  1. Replies: 4
    Last Post: 26th September 2011, 12:02
  2. Replies: 2
    Last Post: 13th October 2010, 21:51
  3. Replies: 0
    Last Post: 4th May 2010, 10:24
  4. Drop indicator not displaying with QTreeView. Need help
    By bigchiller in forum Qt Programming
    Replies: 12
    Last Post: 12th March 2008, 11:38
  5. Drop Indicator
    By guilugi in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2006, 10:49

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.