rewrite this function like this
Qt Code:
  1. inline bool createConnection()
  2. {
  3. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
  4. db.setDatabaseName(" LPSC");
  5. if (!db.open())
  6. {
  7. QMessageBox::critical(0, qApp->tr("Cannot open database"),
  8. qApp->tr("Unable to establish a database connection.\n"
  9. "This example needs SQLite support. Please read "
  10. "the Qt SQL driver documentation for information how "
  11. "to build it.\n\n"
  12. "Click Cancel to exit."), QMessageBox::Cancel);
  13. return false;
  14. }
  15. return true;
  16. }
To copy to clipboard, switch view to plain text mode