I try created my own model for add checkbox in first column tableview.

Qt Code:
  1. #ifndef MODELANGGOTA_H
  2. #define MODELANGGOTA_H
  3.  
  4. #include <QSqlQueryModel>
  5.  
  6. class modelAnggota : public QSqlQueryModel
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. modelAnggota(QObject *parent = 0);
  12. QVariant data(const QModelIndex &item, int role) const;
  13.  
  14. };
  15.  
  16. #endif // MODELANGGOTA_H
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. #include "modelanggota.h"
  2.  
  3. modelAnggota::modelAnggota(QObject *parent)
  4. : QSqlQueryModel(parent)
  5. {
  6.  
  7. }
  8.  
  9. QVariant modelAnggota::data(const QModelIndex &index, int role) const
  10. {
  11. if (role == Qt::CheckStateRole && index.column() == 0)
  12. return Qt::Unchecked;
  13.  
  14. return QSqlQueryModel::data(index, role);
  15. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. QSqlQueryModel *model = new modelAnggota();
  2. model->setQuery("select * from mailbox");
  3.  
  4. ui->tableView->setModel( model );
  5. ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
  6. ui->tableView->setAlternatingRowColors(TRUE);
  7. ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);
  8. ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
To copy to clipboard, switch view to plain text mode 

But checkbox can't checked or unchecked. I need the checkbox not for edited data on table (database), but just for checked. Then, if I Click a pushButton (delete button), row with checked will remove. And yes, row in database table will removed too.


Have any suggestion ?

Sorry. my english is bad