Set cell with icon in table non-editable.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-26 15:45:31 +03:00
parent e0c22b6809
commit 1a218b5edb

View File

@ -105,6 +105,11 @@ void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details)
item->setIcon(QIcon("://icon/16x16/forbid_detail.png")); item->setIcon(QIcon("://icon/16x16/forbid_detail.png"));
} }
item->setData(Qt::UserRole, i.key()); item->setData(Qt::UserRole, i.key());
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidget->setItem(currentRow, 0, item); ui->tableWidget->setItem(currentRow, 0, item);
QString name = det.getName(); QString name = det.getName();
@ -115,9 +120,7 @@ void VWidgetDetails::FillTable(const QHash<quint32, VDetail> *details)
item = new QTableWidgetItem(name); item = new QTableWidgetItem(name);
item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
flags = item->flags();
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags); item->setFlags(flags);