Hi there folks!

First of all I am a bit of a newbie (both in C++ and in Qt), and I am having a bit of trouble with an application I am writing to manage databases.

the following code is giving me a very bad headache...

Qt Code:
  1. void mainwindow::manipdatabase() {
  2. QSqlDatabase *meddb = new QSqlDatabase;
  3. meddb->addDatabase("QMYSQL");
  4. meddb->setHostName ("localhost");
  5. meddb->setDatabaseName ("medadmin");
  6. meddb->setUserName ("medadmin");
  7. meddb->setPassword ("DEEPthoughts1234567890");
  8. if (!meddb->open()) {
  9. QMessageBox::critical(0, qApp->tr("Cannot open database"),
  10. qApp->tr("Unable to establish a database connection.\n"
  11. "This program requires MySql to operate. Please read "
  12. "the Qt SQL driver documentation for information how "
  13. "to build it.\n\n"
  14. "Click Cancel to exit."), QMessageBox::Cancel);
  15. }
  16. QSqlTableModel *model = new QSqlTableModel(0, meddb);
  17. model->setTable ("test");
  18. model->setEditStrategy (QSqlTableModel::OnManualSubmit);
  19. model->select();
  20. model->setHeaderData(1, Qt::Horizontal, QObject::tr("Name"));
  21. model->setHeaderData(2, Qt::Horizontal, QObject::tr("Surname"));
  22.  
  23. ui->View->setWindowTitle ("Patients List");
  24. ui->View->setModel (model);
  25. ui->View->setSelectionBehavior (QAbstractItemView::SelectRows);
  26. ui->View->setSelectionMode (QTableView::SingleSelection);
  27. ui->View->setVisible (true);
  28. }
To copy to clipboard, switch view to plain text mode 

It complains about the line were the model is declared according to qmake "expected QObject", but shouldn't that set the parent widget to none (and therefore work)???

My apologies for being such a newbie, I hope that any of you could please help me (if you want you can always write a little line of code explaining how it should be done).

Thank you in advance,