Results 1 to 2 of 2

Thread: change row color with setData

  1. #1

    Default change row color with setData

    I can easily manipulate data in the QTableView cells with :

    Qt Code:
    1. model->setDate(index, "somestring")
    To copy to clipboard, switch view to plain text mode 

    but I can't change other properties, like background color or smth:

    Qt Code:
    1. model->setData(model->index(1,2) , QColor(Qt::blue), Qt::BackgroundColorRole);
    To copy to clipboard, switch view to plain text mode 
    - doesn't work

    it appears that only default role (Qt::EditRole) works for me in setData... is that's what's supposed to be or I am missing something?

  2. #2
    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: change row color with setData

    The roles that "work" depend on the model. If your model doesn't support storing background colors, it will ignore all requests to set them.
    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. Change the color of QRubberBand
    By franco.amato in forum Qt Programming
    Replies: 14
    Last Post: 4th August 2011, 16:30
  2. Change in color map?
    By bigjoeystud in forum Qwt
    Replies: 4
    Last Post: 8th September 2010, 20:00
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25
  5. [QTable] Change row's color
    By villy in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 19:21

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.