Results 1 to 3 of 3

Thread: Why can't I set backgroung of a QTreeWidget's header item?

  1. #1
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Why can't I set backgroung of a QTreeWidget's header item?

    Hi,

    I was wondering if someone could point out why I can't set background color of a QTreeWidget's header item? I was able to set the foreground of it but cannot change the background color. Here is what I do:

    myTree->setHeaderLabels(QStringList() << "blah" << "blah" << "blah";

    QTreeWidgetItem *header = myTree->headerItem();
    header->setForeground(1, QBrush(Qt::red)); // <<== this works!
    header->setBackground(1, QBrush(Qt::green)); // <<== this does not work!

    Any help is greatly appreciate.
    Sincerely,

    Wieland J.

  2. #2
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Why can't I set backgroung of a QTreeWidget's header item?

    Hello,

    Anybody?
    Sincerely,

    Wieland J.

  3. #3
    Join Date
    Nov 2016
    Posts
    1
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Why can't I set backgroung of a QTreeWidget's header item?

    Hello from the future

    It took me and 3 other guys 48 hours to figure this out and luckily one of us found it.
    Here it is:

    QHeaderView::section {
    background-color: rgb(28, 28, 28);
    color: rgb(215, 215, 215);
    }

    Sorry for taking so long, I hope you found a workaround in the meantime.

    Cheers
    Cedric

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 19:50
  2. QTableWidget NW corner header item?
    By McKee in forum Qt Programming
    Replies: 9
    Last Post: 31st May 2012, 00:44
  3. QHeaderView: background of selected header item with CSS
    By antarctic in forum Qt Programming
    Replies: 5
    Last Post: 8th June 2009, 08:37
  4. Replies: 2
    Last Post: 24th May 2009, 11:27
  5. QTreeWidget's Item Widgets
    By jpn in forum Qt Programming
    Replies: 11
    Last Post: 2nd April 2006, 00:56

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.