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:
Qt Code:
  1. proxyModel = new SortFilterProxyModel();
  2.  
  3. treeView = new QTreeView();
  4. treeView->setModel(proxyModel);
  5.  
  6. sqlModel = new QSqlQueryModel(this);
  7. proxyModel->setSourceModel(sqlModel);
To copy to clipboard, switch view to plain text mode 

And this is my code that gets the wrong row:

Qt Code:
  1. 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!