Thanks for the reply -- I was trying to figure out the tags but the only one I saw was the "Qt" one and that do exactly what it was I wanted...I see the # sign now...

Thanks for suggestion...I don't need to use this data outside of this model and I'll try to hide it, but what's concerning me is that the row isn't actually being removed from the database...I thought the submitALL() would take care of that...

Obviously I'm still coming up to speed in a stupidly short amount of time...I might try to use a different approach all together tonight -- it just occurred to me that I need to timestamp a field before it gets written out to the DB...Either that or I find a way to add that into the model when a row is either created or modified...

'Preciate the guidance!

scott

Reposted with tags

Qt Code:
  1. void MainWindow::on_AdminPB_clicked()
  2. {
  3. //*********************************************
  4. //* Retrieve data from the USER table for managing... *
  5. //*********************************************
  6. usertablemodel = new QSqlTableModel(this);
  7.  
  8. usertablemodel->setTable ("user");
  9. usertablemodel->setEditStrategy (QSqlTableModel::OnManualSubmit);
  10. usertablemodel->select ();
  11.  
  12. usertablemodel->setHeaderData (0, Qt::Horizontal,
  13. QObject::tr("Username"));
  14. usertablemodel->setHeaderData (1, Qt::Horizontal,
  15. QObject::tr("Password"));
  16. ....
  17.  
  18. ui->ManageUsersTV->setModel (usertablemodel);
  19. ui->ManageUsersTV->show ();
  20.  
  21. ui->ManageUsersTV->setEditTriggers (QAbstractItemView::AnyKeyPressed |
  22. QAbstractItemView::DoubleClicked);
  23. }
  24.  
  25. void MainWindow::on_InsertUserPB_clicked()
  26. {
  27.  
  28. int row = usertablemodel->rowCount ();
  29. usertablemodel->insertRows(row,1);
  30.  
  31. }
  32.  
  33. void MainWindow::on_DeleteUserPB_clicked()
  34. {
  35. usertablemodel->removeRows(ui->ManageUsersTV->currentIndex().row(), 1);
  36. }
  37.  
  38. void MainWindow::on_SaveUserPB_clicked()
  39. {
  40. if (!usertablemodel->submitAll ())
  41. qDebug() << usertablemodel->lastError ();
  42. }
To copy to clipboard, switch view to plain text mode