Results 1 to 5 of 5

Thread: QTreeWidgetItem: reset background color

  1. #1
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeWidgetItem: reset background color

    How do you reset the background of a QTreeWidgetItem?
    I know how to set the background to another color - setBackground(0, QColor(202, 224, 232, 255)); - but putting it back?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidgetItem: reset background color

    Try:
    Qt Code:
    1. item->setBackground(column, QBrush());
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    aliks-os (30th January 2016), supergillis (3rd August 2008)

  4. #3
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItem: reset background color

    Works like a charm
    Thanks!

  5. #4
    Join Date
    Aug 2008
    Posts
    35
    Thanks
    7
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTreeWidgetItem: reset background color

    But now, when using sorted QTreeWidget, the item with another brush gets sorted in front.
    Example:
    I got a music list. That list contains songs of AC/DC. You got the song 'Thunderstruck' and 'Back in Black'. When you order the tree on artist, and you play the song 'Thunderstruck' it changes the background color to green and 'Thunderstruck' suddenly pops in front of 'Back in Black'... If you know what I mean...

    I tried resorting after changing the brush but that doesn't make any difference.

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidgetItem: reset background color

    Could you prepare a minimal compilable example which reproduces the problem?
    J-P Nurmi

Similar Threads

  1. QTreeWidgetItem and background color
    By swiety in forum Qt Programming
    Replies: 9
    Last Post: 26th October 2016, 07:25
  2. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  3. how to change QTextEdit background color ?
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 26th June 2008, 22:05
  4. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25
  5. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 15:36

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.