Hi,
I try to have a checkBox inside a QtableView. For the moment, I try differents solutions (delegate, ..), but I'am not happy with the result. This is the code, I have for the moment
Column 5 must be a checkBox
class MyItemModel is derivated from QStandardItemModel

Qt Code:
  1. bool MyItemModel::setData ( const QModelIndex & index, const QVariant & value, int role)
  2. {
  3. if (index.column()==5)
  4. {
  5. if (role==Qt::CheckStateRole)
  6. return QStandardItemModel::setData(index,value,role);
  7. return false;
  8. }
  9. else
  10. return QStandardItemModel::setData(index,value,role);
  11.  
  12. }
  13. QVariant MyItemModel::data ( const QModelIndex & index, int role ) const
  14. {
  15. if (index.column()==5)
  16. {
  17. if (role==Qt::CheckStateRole)
  18. return QStandardItemModel::data(index,role);
  19. return QVariant();
  20. }
  21. else
  22. return QStandardItemModel::data(index,role);
  23. }
  24. Qt::ItemFlags MyItemModel::flags( const QModelIndex & index ) const
  25. {
  26. if (index.column()==5)
  27. return Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable;
  28. return Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsUserCheckable|Qt::ItemIsSelectable;
  29. }
  30.  
  31. When I add a line, I use this call
  32. setData(model->index(0, 5), Qt::Checked,Qt::CheckStateRole);
To copy to clipboard, switch view to plain text mode 

With that, I have a checkbox, but it's not centered and there is a text zone (I can edit it, if I put the flag Qt::ItemIsEditable). I woul like to remove the edit zone and center the check box.
Thank for your help
Laurent