标签:
修改该列item的flags. 例如:
#include <QApplication>
#include <QTableWidget>
#include <QTableWidgetItem>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
int col = 0;
QTableWidget *table = new QTableWidget(5, 3);
table->setItem(0, col, new QTableWidgetItem(QString("test")));
int i;
for(i = 0; i < table->rowCount(); i++){
QTableWidgetItem *item = table->item(i, col);
if(item) {
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
} else {
item = new QTableWidgetItem;
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
table->setItem(i, col, item);
}
}
table->show();
return app.exec();
}
qt 下tablewidget 中要单独使一列不能编辑怎么办?
标签:
原文地址:http://www.cnblogs.com/hittie/p/4340579.html