Results 1 to 2 of 2

Thread: Problem with row coloring in qtableview

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with row coloring in qtableview

    Hello,

    I am using following code to assign data and color to contents of QTableView:

    Qt Code:
    1. for(y=0; y<7; y++)
    2. {
    3. if(y==6)
    4. {
    5. if(nepopolno)
    6. item->setData("krizec",Qt::DisplayRole);
    7. else
    8. item->setData("kljukica",Qt::DisplayRole);
    9.  
    10. }
    11. else
    12. item->setData(ukaz.value(y).toString(),Qt::DisplayRole);
    13.  
    14. item->setData(ukaz.value(6).toString(),Qt::UserRole);
    15.  
    16. item->setBackground(Qt::red);
    17. model.setItem(vrsta,y,item);
    18. }
    To copy to clipboard, switch view to plain text mode 

    Variable y represents column as you can see. Problem I face is that only first column is colored. If I debug with debugger, then I see that item->setBackground() method is certainly called for every QStandardItem of model that is assigned to QTableView.
    Any clues how to write this code correctly? Or is there some other issue with Qt?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Problem with row coloring in qtableview

    Try writing a simple delegate
    See the Qt examples

Similar Threads

  1. QMenu stylesheet and alpha coloring
    By StaticPhilly in forum Newbie
    Replies: 1
    Last Post: 11th October 2010, 17:38
  2. Coloring a QTableview column
    By Potch in forum Qt Programming
    Replies: 2
    Last Post: 5th April 2009, 00:18
  3. Coloring checkable QPushbutton with style sheet
    By RThaden in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 19:11
  4. Coloring of Radio Button
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd July 2008, 16:05
  5. qcombobox back ground coloring
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 20:29

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.