QTableView commit data in code
-
Meanwhile, my solution is something like (inside my manual save function)
@
QModelIndex ndx = ui->tableView->currentIndex();
if (ndx.isValid()) {
ui->tableView->setCurrentIndex( tbl->index(ndx.row(), 0));
ui->tableView->setCurrentIndex( tbl->index(ndx.row(), 1));
}
@
which only works if there are at least 2 columns, but at least it works. -
Ok... if I understand it correctly though, it can only work with subclassing?
-
You are talking about QTableView's endEdit() function?
Isn't that a protected function (so I need to subclass QTableView)? -
I'm sorry for insisting, but I don't understand something.
You are talking about a function that contains
@
void AnyClass::endEdit()
{
QModelIndex index = myTblVw->currentIndex();
myTblVw->currentChanged( index, index );
}
@
How do I get access to the auto-generated text edit of the QTableView, so I can wire it to this slot?
Also, isn't currentChanged protected too? -
I must be missing something very obvious here, because it's not working for me.
Inside my Qt class that owns the QTableView (say it's a variable named myTblVw) , I can't call
myTblVw->currentChanged(...) from my save() slot because it's a protected method.So you are saying I should create another class deriving from anything, and write a function like in the previous posts? How does that class get access to the QTableView? Even if I were to pass a pointer to myTblVw, it still won't be able to call the protected method.
How is this going to work without subclassing?