Solved it!

Nice solution. I removed my delegate and reimplemented these functions in my model:
Qt Code:
  1. /* Reimplemented function: flags
  2.  * Set the att coulumn editable flag
  3.  */
  4. Qt::ItemFlags EconomyHoursModel::flags( const QModelIndex &index ) const
  5. {
  6. Qt::ItemFlags flags = QSqlQueryModel::flags( index );
  7.  
  8. if( index.column() == 5 )
  9. flags |= Qt::ItemIsEditable | Qt::ItemIsUserCheckable;
  10.  
  11. return flags;
  12. }
  13.  
  14. /* Reimplemented function: data
  15.  * Have to reimplement this in order to show a checkbox when not editing the table
  16.  */
  17. QVariant EconomyHoursModel::data(const QModelIndex &index, int role) const
  18. {
  19. QVariant ret;
  20.  
  21. if( role == Qt::CheckStateRole && index.column() == 5 )
  22. {
  23. if( QSqlQueryModel::data( index, Qt::DisplayRole ).toString() == "" )
  24. ret = Qt::Unchecked;
  25. else
  26. ret = Qt::Checked;
  27. }
  28. else if( role == Qt::DisplayRole && index.column() == 5 ) //Don't show date as text
  29. {
  30. ret = QVariant();
  31. }
  32. else
  33. {
  34. ret = QSqlQueryModel::data( index, role );
  35. }
  36.  
  37. return ret;
  38. }
  39.  
  40. /* Reimplemented function: setData
  41.  * Sets data for the att column
  42.  */
  43. bool EconomyHoursModel::setData( const QModelIndex &index, const QVariant &value, int role )
  44. {
  45. bool ret = false;
  46.  
  47. if( role == Qt::CheckStateRole )
  48. {
  49. if( index.column() != 5 )
  50. return false;
  51.  
  52. QModelIndex idIndex = QSqlQueryModel::index( index.row(), 0 );
  53.  
  54. int id = data( idIndex ).toInt();
  55.  
  56. QString storeValue = "";
  57.  
  58. if( value.toInt() == Qt::Checked )
  59. storeValue = QDate::currentDate().toString( "yyyy-MM-dd" );
  60.  
  61. clear();
  62.  
  63. QSqlQuery query;
  64. query.prepare( "UPDATE hours SET att=? WHERE id=?" );
  65. query.addBindValue( storeValue );
  66. query.addBindValue( id );
  67.  
  68. ret = query.exec();
  69.  
  70. if( ret )
  71. refresh();
  72. }
  73. else
  74. {
  75. ret = QSqlQueryModel::setData( index, value, role );
  76. }
  77.  
  78. return ret;
  79. }
To copy to clipboard, switch view to plain text mode 

Thanks for pointing me in the right direction!!!

//John