{
for (int i = 0; i < tbl.rowCount(); i++)
for (int j = 0; j < tbl.columnCount(); j++)
if (!(tbl.item(i, j)->row() == allowed.row() &&
tbl.item(i, j)->column() == allowed.column()))
tbl.item(i, j)->setFlags(Qt::NoItemFlags);
}
int main(int argc, char * argv[])
{
tbl.setRowCount(1);
tbl.setColumnCount(3);
tbl.setItem(0, 0, item1);
tbl.setItem(0, 1, item2);
tbl.setItem(0, 2, item3);
DisableAllExceptOne(tbl, *item1);
tbl.show();
return a.exec();
}
void DisableAllExceptOne(QTableWidget & tbl, const QTableWidgetItem & allowed)
{
for (int i = 0; i < tbl.rowCount(); i++)
for (int j = 0; j < tbl.columnCount(); j++)
if (!(tbl.item(i, j)->row() == allowed.row() &&
tbl.item(i, j)->column() == allowed.column()))
tbl.item(i, j)->setFlags(Qt::NoItemFlags);
}
int main(int argc, char * argv[])
{
QApplication a(argc, argv);
QTableWidget tbl;
tbl.setRowCount(1);
tbl.setColumnCount(3);
QTableWidgetItem * item1 = new QTableWidgetItem("ONE");
tbl.setItem(0, 0, item1);
QTableWidgetItem * item2 = new QTableWidgetItem("TWO");
tbl.setItem(0, 1, item2);
QTableWidgetItem * item3 = new QTableWidgetItem("THREE");
tbl.setItem(0, 2, item3);
DisableAllExceptOne(tbl, *item1);
tbl.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks