PDA

View Full Version : QTableView Edit Focus



waynew
16th August 2010, 02:18
I have a table view in a form. When the user clicks the add button to add a new record, I would like to put the focus on the first column in the new record for editing, so the cursor should be there as soon as the user clicks the add button.

I've gotten as far as adding the new record and getting the row selected, but I'm stuck on how to get the first column editable with the cursor in it.

It works ok if you double click the first column for editing, but I would like the program to do that for the user.

I tried this since the row is already selected by the program:


QModelIndex index = ui->tvMemories->currentIndex();
ui->tvMemories->edit(index);

Doesn't do what I need. Someone must have figured out how to do this already?
Thanks for any ideas.

aamer4yu
16th August 2010, 05:44
Is the item editable ? :rolleyes:
and if yes,, what are the triggers that invoke editing ?

waynew
16th August 2010, 12:24
Yes, if you double click in a cell on the selected row, you can edit it.
The triggers are set to "all"
ui->tvMemories->setEditTriggers(QAbstractItemView::AllEditTriggers );