Results 1 to 4 of 4

Thread: How do I control the QTableView row selection color when the control loses focus?

  1. #1
    Join Date
    Jul 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default How do I control the QTableView row selection color when the control loses focus?

    By default, the QTableView changes the selection color to grey when the control loses focus. I would like to remove this behavior and have the selection color be blue regardless of focus. How do I achieve this?

  2. #2
    Join Date
    Feb 2014
    Posts
    43
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I control the QTableView row selection color when the control loses focus?

    Have you tried this ?
    viewOption.palette.setColor(QPalette::Text, getColor(QColor);
    Also use setAlternatingRowColors(true);

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

    Default Re: How do I control the QTableView row selection color when the control loses focus?

    More probably:

    Qt Code:
    1. QPalette p = palette();
    2. p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight));
    3. setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    or similar.
    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.


  4. #4
    Join Date
    Jul 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How do I control the QTableView row selection color when the control loses focus?

    That worked! Thanks!!

Similar Threads

  1. QGraphicsProxywidget / delegate control focus confusion
    By jamierobertson in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2013, 20:27
  2. How to control the color of the focus rectangle
    By Berryblue031 in forum Qt Programming
    Replies: 2
    Last Post: 21st June 2012, 13:55
  3. How to set focus on control
    By sq_vasya in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2010, 20:06
  4. Replies: 2
    Last Post: 8th October 2010, 07:03
  5. Replies: 0
    Last Post: 16th December 2009, 09:45

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.