QTableWidget 设置特定的列不可编辑
0. Qt助手
void QTableWidgetItem::setFlags(Qt::ItemFlags flags)
Sets the flags for the item to the given flags. These determine whether the item can be selected or modified.
See also flags().
Qt::ItemFlags QTableWidgetItem::flags() const
Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.
See also setFlags().
Qt::ItemIsEditab | 2 | It can be edited |
1. 代码
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
ui->tableWidget->verticalHeader()->setVisible(false); //隐藏垂直的序号
ui->tableWidget->setColumnCount(2