Results 1 to 3 of 3

Thread: Trying to change the background of a QTreeWidget

  1. #1
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Trying to change the background of a QTreeWidget

    After a lot of searching, I'm gonna ask

    I have a QTreeWidget on a dialog. The user requirement is that the background of the tree is the same color as QPalette::Window (and the palette can change, so just modifying the palette in designer won't work). I've tried tree->setBackgroundRole(QPalette::Window) (and even foreground role)... no difference.

    If I modify the items (item->setBackground(QApplication:alette().window())), the item backgrounds are right... but the tree widget w/o items is still white (base).

    Using qt 4.3.2 --- and ready to tear my hair out, since this seems to function in other places, just not the tree widget.

    Vycke

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trying to change the background of a QTreeWidget

    from the docs :

    QPalette::ColorRole
    QPalette::Background Window This value is obsolete. Use Window instead.
    also try tree->viewport()->setPallete() if the color doesnt work
    also try using setAutoFillBackground() function while setting the color.

    Hope this helps

  3. The following user says thank you to aamer4yu for this useful post:

    vycke (15th April 2008)

  4. #3
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Trying to change the background of a QTreeWidget

    Quote Originally Posted by aamer4yu View Post
    from the docs :

    also try tree->viewport()->setPallete() if the color doesnt work
    also try using setAutoFillBackground() function while setting the color.

    Hope this helps
    Ok, it works with:

    tree->viewport()->setBackgroundRole(QPalette::Window);

    Woot!

    Thanks,

    Vycke

Similar Threads

  1. Change background color of QPushButton
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2013, 10:23
  2. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 07:14
  3. Replies: 5
    Last Post: 10th April 2008, 09:52
  4. Change background color for a QPushButton?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 5th January 2007, 14:23
  5. Change column width in a QTreeWidget
    By mace in forum Qt Programming
    Replies: 2
    Last Post: 27th May 2006, 12:19

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.