Results 1 to 3 of 3

Thread: How to change color of single header cell?

  1. #1

    Default How to change color of single header cell?

    Hello. I have a QStandardItemModel, with QStandardItems in it, all in QTableView.

    I have to make certain column headers to be different color and possibly different text. Let's post an example table then:
    help.jpg
    As you can see first colum and first row font is different because I tried changing color and other stuff in it with this:
    Qt Code:
    1. QStandardItem *col1 = new QStandardItem("Column 1");
    2. col1->setForeground(Qt::red);
    3. col1->setBackground(Qt::green);
    4. col1->setFont(QFont("arial", 11));
    5.  
    6. setHorizontalHeaderItem(0, col1);
    To copy to clipboard, switch view to plain text mode 

    So changing font works just fine, but colors, nope...
    any ideas?

  2. #2

    Default Re: How to change color of single header cell?

    Nothing ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to change color of single header cell?

    Maybe the widget style you use does not allow that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 31st October 2014, 20:45
  2. Replies: 7
    Last Post: 25th July 2013, 21:47
  3. Replies: 2
    Last Post: 17th July 2010, 21:07
  4. Replies: 1
    Last Post: 7th December 2009, 18:56
  5. QTableView change color of current Cell
    By raphaelf in forum Qt Programming
    Replies: 4
    Last Post: 4th March 2006, 11:22

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
  •  
Qt is a trademark of The Qt Company.