Results 1 to 2 of 2

Thread: QPainter with TreeView

  1. #1
    Join Date
    Aug 2008
    Posts
    9
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default QPainter with TreeView

    If I override drawRow() in my QTreeView subclass and place only a call to the base class's drawRow, and pass the same parameters I received, the tree will draw normally.

    If I take the QPainter parameter and call setPen(Qt::red) followed by base::drawRow(), the tree will draw normally except for items with children. Those items will have the '+' or '-' expansion symbol drawn in red. The text is not red.

    I don't understand why drawRow takes a QPainter parameter if it doesn't use it. Calling the item delegate's paint() draws the text in the wrong location but in the same default color.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPainter with TreeView

    It does use the painter.
    However, it is possible that a setting is overwritten e.g. when a style's value is used. The colors returned in your model's data function will also (at some time) be set in the QPainter.

    Therefore, if you want to change that colors,
    * use a (Proxy)Style. (Search forum for details).
    * use a style sheet

Similar Threads

  1. QPainter update()
    By csvivek in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2008, 09:42
  2. QPainter
    By phil_ in forum Newbie
    Replies: 5
    Last Post: 16th December 2006, 19:54
  3. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. Replies: 7
    Last Post: 20th March 2006, 20:03

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.