Results 1 to 2 of 2

Thread: Change the selection color of a QTableWidget but only for some cells

  1. #1
    Join Date
    Sep 2011
    Posts
    51
    Thanks
    2
    Qt products
    Qt4

    Default Change the selection color of a QTableWidget but only for some cells

    Good morning,
    i've a table Qtablewidget.

    when i click a row it is selected with a colour.

    I need that if some cells of the row have a defined background color, this background color must remain and no overridden by the selection color.

    So the row selected will be with the selection color, but some cells will remain with their original background color.

    Is there any example ?

    Thanks to all

  2. #2
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change the selection color of a QTableWidget but only for some cells

    I've done something similar to this. I implemented a custom QItemViewDelegate with an overridden paint(QPainter*, const QStyleOptionViewItem& opt, const QModelIndex&)-method. In my method i call the base-class's paint-method with a modified QStyleOptionViewItem where i've set the palette's QPalette::Highlight-role to my custom selection color.

Similar Threads

  1. change color/focus in qtablewidget
    By mmm286 in forum Newbie
    Replies: 7
    Last Post: 5th June 2013, 03:58
  2. Qtablewidget and selection color
    By gab74 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2013, 09:38
  3. Replies: 2
    Last Post: 17th July 2010, 21:07
  4. Replies: 4
    Last Post: 17th July 2010, 04:47
  5. Replies: 2
    Last Post: 11th March 2009, 02:00

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.