I have a TreeView that is feeded by a SortFilterProxyModel that is feeded by a SqlQueryModel.
Now I want to add double click event so that an edit dialog is loaded with data from the selected row and can be edited.
But all I get is a "random" row to be loaded, it's like the TreeView current index is wrong. My guess is that the SortFilterProxyModel is messing it up, but I have no clue on how to get the right index.
This is how I set my models:
proxyModel = new SortFilterProxyModel();
treeView->setModel(proxyModel);
proxyModel->setSourceModel(sqlModel);
proxyModel = new SortFilterProxyModel();
treeView = new QTreeView();
treeView->setModel(proxyModel);
sqlModel = new QSqlQueryModel(this);
proxyModel->setSourceModel(sqlModel);
To copy to clipboard, switch view to plain text mode
And this is my code that gets the wrong row:
QSqlRecord product
= sqlModel
->record
(treeView
->currentIndex
().
row());
QSqlRecord product = sqlModel->record(treeView->currentIndex().row());
To copy to clipboard, switch view to plain text mode
I'm a newbie on QT but I've looked everywhere on the net and couldn't find an answer, so I'm hoping someone here can help me!
Bookmarks