Results 1 to 2 of 2

Thread: color of table cells

  1. #1

    Default color of table cells

    Hi all,

    maybe this is a repetition but I just could not get ot working. My question is simple:
    just wanted to make so cells in the QTableView colored when the data fulfill certain conditions.

    atm, my code looks like this:

    Qt Code:
    1. void MainInterface::colorWarning()
    2. {
    3. int rownumber;
    4. for(rownumber=0;rownumber<=100; rownumber++) {
    5. QModelIndex idindex = mui.tableViewPersonTable->model()->index(rownumber, 9, QModelIndex())
    6. if (idindex.isValid()){
    7. QString dateString = idindex.data().toString();
    8. QDate date = QDate::fromString(dateString, "yyyy-MM-dd");
    9. QDate today = QDate::currentDate();
    10. int daysafter = date.daysTo(today);
    11. if (daysafter >= 30) {
    12. mui.tableViewPersonTable->model()->setData(idindex, Qt::green, Qt::BackgroundRole))
    13. }
    14. }
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    thanks!!!
    Last edited by rickym; 22nd January 2007 at 21:22.

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: color of table cells

    Have you tried listening for a dataChanged signal (using a QSignalSpy). If the signal is not emitted explicitly from the setData method the view will never know that the data has changed.

Similar Threads

  1. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12
  2. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 22:12
  3. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13:50
  4. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 18:06
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

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.