PDA

View Full Version : QSqlTableModel Questions



munna
4th March 2006, 07:22
Hi,

1. setFilter(cosnt QString &)

How can I set more than one filter ? Ex: first_name = 'something' and last_name = 'another'

2. insertRecord(int row,......) and setRecord(int row,.......)

Is the row number related to the current query or the table?
Where would the new row get added in the database?
How should the primary key be generated for the new record?

Thanks a lot

wysota
4th March 2006, 09:35
1. setFilter(cosnt QString &)

How can I set more than one filter ? Ex: first_name = 'something' and last_name = 'another'


setFilter("first_name = 'something' and last_name = 'another'");


2. insertRecord(int row,......) and setRecord(int row,.......)

Is the row number related to the current query or the table?
It is related to the model. row represents the index of the model.


Where would the new row get added in the database?
Depends on the row you enter and the way the underlying database works. For most uses -- "at the end".


How should the primary key be generated for the new record?
It should be autogenerated by the database or by your model's "insertRow()" (if you use a custom model).

munna
4th March 2006, 10:41
when i set a filter, my model changes. rite?

wysota
4th March 2006, 11:11
No. You have to call select() to update the model.