Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1.   QSqlRecord newRecord = model->record();
  2.     newRecord.setValue("owner", QVariant("John Grisham"));
  3.     newRecord.setValue("parcelleFile", QVariant("The Litigators"));
  4.     newRecord.setValue("type", QVariant("test"));
  5.     newRecord.setValue("speed",QVariant(10));
  6.   //  qDebug() << "Insert row" << model->insertRecord(model->rowCount(), newRecord);
  7.  
  8.     /*-1 is set to indicate that it will be added to the last row*/
  9.  
  10.     if(model->insertRecord(-1, newRecord))
  11.         qDebug()<<"successful insertion" << newRecord.value("owner") << "was its owner";
  12.     model->submitAll();
  13.     QSqlRecord  writtenRec( model->record(model->rowCount() - 1 ) );
  14.     qDebug() << "owner of inserted record: " << writtenRec.value("owner") << "row field name 0" << writtenRec.fieldName(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement