[Qt-interest] QSqlTableModel and getting a QModelIndex based on a primary key.

MARTIN Pierre hickscorp at gmail.com
Mon Sep 26 15:05:36 CEST 2011


Oh i forgot. i want to avoid calling setFilter on my model... Because many views are connected to it, and they should not be filtered by the logic behind my controller's row retrieval.

> Hello dear list users,
> 
> i am asking myself a question before going into implementing something which could be useless.
> i have a QSqlTableModel-derived model. This class is working on a table named "Foo", and it sets it's primary key to "id", which is in the table a classic unique auto-incremented int.
> Now let's say i have a primary key value, and i want the corresponding QModelIndex from my model... What would be the best way to proceed? Using fetchMore while canFetchMore and then iterate thru all records?
> 
> Is there anything usable in the existing implementations of QSqlQueryModel / QSqlTableModel?
> 
> Thank you,
> Pierre.
> 




More information about the Qt-interest-old mailing list