Hello,
Is there any way to get the rowid from a Sqlite table's row using QSqlTableModel?
I tried the following line but it didn't works:
Code:
model->record(currentSelection.at(0).row()).value("rowid")
Thanks in advance
:)
Printable View
Hello,
Is there any way to get the rowid from a Sqlite table's row using QSqlTableModel?
I tried the following line but it didn't works:
Code:
model->record(currentSelection.at(0).row()).value("rowid")
Thanks in advance
:)
Does your table have a column declared "INTEGER PRIMARY KEY" or "INTEGER PRIMARY KEY AUTO_INCREMENT"? If so then these are the rowid value... but then you already have a unique identifier and wouldn't be asking this question.
Since the QSqlTableModel effectively executes "select * from table" and the rowid is not returned in that result then I suspect you are out of luck. For a read-only model you could use QSqlQueryModel and explicitly fetch the rowid.
What do you want to achieve?
Many thanks ChrisW67
I am going to use an id declared as INTEGER PRIMARY KEY AUTO_INCREMENT to get a unique identifier.