I have a problem with method lastInsertId. I'm using a PostgreSql 8.4 and Qt 4.6.3 under Linux. I have a code like this:
Qt Code:
  1. // _model is a QSqlTableModel
  2. QSqlRecord record = _model->record();
  3. _model->insertRecord( -1, record );
  4.  
  5. SomeDialog* dialog = new SomeDialog( _model );
  6. dialog->exec();
  7. if( dialog->result() == QDialog::Accepted )
  8. {
  9. bool ok = _model->submitAll();
  10. if( ok )
  11. {
  12. // allways 0 but in db is a new record
  13. qDebug() << _model->query().lastInsertId().toInt();
  14. }
  15. else
  16. {
  17. qDebug() << _model->lastError().text();
  18. }
  19. }
To copy to clipboard, switch view to plain text mode 

My table looks like this:
Qt Code:
  1. CREATE TABLE mytable
  2. (
  3. id serial NOT NULL,
  4. field1 text,
  5. CONSTRAINT mytable_pkey PRIMARY KEY (id),
  6. )
  7. WITH (
  8. OIDS=TRUE
  9. );
To copy to clipboard, switch view to plain text mode 

How can I get a inserted ID? I need select new row in QTableView and I need this information.