Results 1 to 6 of 6

Thread: On mouse click changing selection's background color in tableview

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Apr 2015
    Posts
    20
    Thanks
    7
    Qt products
    Platforms
    Unix/X11

    Default Re: On mouse click changing selection's background color in tableview

    THANKS for replying.

    But theres some initial problems with this approach.

    Playing here with backgroundRole and the brush, if I use this code to color every other row green. Well the problem is that it is the background color of the cell
    not the color of the selection indicator. So I am assuming it might not even be visible if I managed to call from view a change in model with custom setData() method.
    Qt Code:
    1. elif role == Qt.BackgroundRole:
    2. if index.row() % 2 == 0:
    3. return QBrush(Qt.green)
    To copy to clipboard, switch view to plain text mode 
    But will play with it more I guess and try to make it work, I only need to indicate to user that shit went wrong on double click(text in status bar is already telling that but I feel some color emphasis would be nice), so flashing background of all rows red for 0.2sec would serve well as notice of this, even if bit less elegant than just that row...

    Last edited by DoTheEvo; 25th January 2016 at 10:52.

Similar Threads

  1. Replies: 4
    Last Post: 3rd July 2014, 14:52
  2. Setting the background color of a header in TableView
    By sunilqt in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2013, 13:06
  3. Replies: 6
    Last Post: 27th September 2012, 23:44
  4. changing background color in qvfb
    By John Douma in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 31st March 2011, 19:30
  5. Replies: 1
    Last Post: 22nd February 2010, 09:38

Tags for this Thread

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.