I created a simple ItemDelegate that shows a custom editor on one of my TableView columns. Editing the items in this column works perfectly when using the standard mechanism (double-click on cell, make changes in editor, select another cell).
I made a change that the editor will be opened persistent on the current selected row:
{
// Update persistent InputColumn editor.
ruleTableView->closePersistentEditor(ruleTableView->model()->index(previous.row(), RuleTableModel::InputColumn));
ruleTableView->openPersistentEditor(ruleTableView->model()->index(current.row(), RuleTableModel::InputColumn));
void MainWindow::ruleTableViewSelectedRowChanged(const QModelIndex & current, const QModelIndex & previous)
{
// Update persistent InputColumn editor.
ruleTableView->closePersistentEditor(ruleTableView->model()->index(previous.row(), RuleTableModel::InputColumn));
ruleTableView->openPersistentEditor(ruleTableView->model()->index(current.row(), RuleTableModel::InputColumn));
To copy to clipboard, switch view to plain text mode
Now changes to the editor will not be saved when changing the row unless I hit enter while having the editor selected.
I tried the behaviour of a standard ItemDelegate (SpinBox) and the changes to it will be saved, so I assume I need to change my custom ItemDelegate to commit changes directly when something is changed and not only when setModelData gets called?
Thanks in advance,
-Jens
Bookmarks