Important: Please read the Qt Code of Conduct -

Is this a bug on the Model-View (QTableView-QSqlQueryModel)?

  • Last time on one of my projects I encountered an odd problem.

    I used QTableView and QSqlQueryModel. At first when it is created, "currentIndex" will be NULL (not point to any indexes/items) since no part of the view is selected. When a row or item is selected, currentIndex changes and will have a value.

    BUT, when I click on the vacant part of the view (usually at the bottom or at right since the table is not stretched and there are few entries), currentIndex still points to the "last" index which I supposedly be CLEARED. What I did, is to do a small "hack by subclassing" on the QTableView to emit a signal when the blank area is clicked then did other stuff to clear the currentIndex

    So the question is, Is it actually normal for the view to still have a value on the currentIndex even items are unselected? It should be "lastIndex" (though it is not present in QTableView) and not "currentIndex" to have the value.

    Is it normal or a bug?

Log in to reply