Try this:
Add the following to tab::tab (i.e. the constructor):
ui->tableWidget->setItemDelegateForColumn(2,new myTableDelegate());
ui->tableWidget->setItemDelegateForColumn(3,new myTableDelegate());
connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(cell_clicked(int, int)));
ui->tableWidget->setItemDelegateForColumn(2,new myTableDelegate());
ui->tableWidget->setItemDelegateForColumn(3,new myTableDelegate());
connect(ui->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(cell_clicked(int, int)));
To copy to clipboard, switch view to plain text mode
Remove these lines from tab:: on_bt_show_clicked():
//ui->tableWidget->setItemDelegate(new myTableDelegate());
// ui->tableWidget->setEditTriggers(QAbstractItemView::SelectedClicked);
//ui->tableWidget->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
//ui->tableWidget->setItemDelegate(new myTableDelegate());
// ui->tableWidget->setEditTriggers(QAbstractItemView::SelectedClicked);
//ui->tableWidget->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
To copy to clipboard, switch view to plain text mode
And create a custom slot:
void tab::cell_clicked(int row, int col) {
if(ui->tableWidget->item(row, col)->checkState() == Qt::Checked) ui->tableWidget->item(row, col)->setCheckState(Qt::Unchecked);
else ui->tableWidget->item(row, col)->setCheckState(Qt::Checked);
}
void tab::cell_clicked(int row, int col) {
if(ui->tableWidget->item(row, col)->checkState() == Qt::Checked) ui->tableWidget->item(row, col)->setCheckState(Qt::Unchecked);
else ui->tableWidget->item(row, col)->setCheckState(Qt::Checked);
}
To copy to clipboard, switch view to plain text mode
Be sure to declare the slot in "tab.h"
HTH
Bookmarks