llemes4011
20th October 2010, 21:38
Hello,
I am working with a QTableWidget the user will enter data into, but I cannot get the cells to become editable. Right now I'm doing the following:
void MyClass::initTable(){
// Add Cell 1
QTableWidgetItem *item = new QTableWidgetItem;
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
item->setData(Qt::DisplayRole, "(0,0)");
tableWidget->setItem(0,0,item);
// Add Cell 2
item = new QTableWidgetItem;
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
item->setData(Qt::DisplayRole, "(1,0)");
tableWidget->setItem(1,0,item);
tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers );
}
This is just an example, but it shows what I'm trying to do. I also have an Editor that's being applied to QColor objects that are inserted into the table. I don't know if that would change how it functions, but I figured it wouldn't hurt to mention. It's the Editor that's straight out of the Qt Tutorials.
Also, every other time I've tried to enter data into a table, it has worked. but not for this project. I don't know if it's the current version of Qt or what...
Thanks =)
I am working with a QTableWidget the user will enter data into, but I cannot get the cells to become editable. Right now I'm doing the following:
void MyClass::initTable(){
// Add Cell 1
QTableWidgetItem *item = new QTableWidgetItem;
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
item->setData(Qt::DisplayRole, "(0,0)");
tableWidget->setItem(0,0,item);
// Add Cell 2
item = new QTableWidgetItem;
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
item->setData(Qt::DisplayRole, "(1,0)");
tableWidget->setItem(1,0,item);
tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers );
}
This is just an example, but it shows what I'm trying to do. I also have an Editor that's being applied to QColor objects that are inserted into the table. I don't know if that would change how it functions, but I figured it wouldn't hurt to mention. It's the Editor that's straight out of the Qt Tutorials.
Also, every other time I've tried to enter data into a table, it has worked. but not for this project. I don't know if it's the current version of Qt or what...
Thanks =)