Solved QSqlError, variable has incomplete type 'const QSqlError' ?
-
I'm trying to connect to an Sql database (MySQL), my code:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName(itrHost->toString()); db.setDatabaseName(itrDB->toString()); db.setUserName(itrUsr->toString()); db.setPassword(itrPass->toString()); bool blnOpen = db.open(); if ( blnOpen == true ) { pobjScriptEng->evaluate(strOnConnect + "(\"dbConnect(), connected!\");"); } else { const QSqlError err = db.lastError(); }
I'm having problems with implement the error handler, I get:
calling 'lastError' with incomplete return type 'QSqlError' variable has incomplete type 'const QSqlError'
I can't find an example that does the same sort of thing, what haven't I done?
-
@SPlatten said in QSqlError, variable has incomplete type 'const QSqlError' ?:
what haven't I done?
Make the class known to the compiler by including it's header
#include <QSqlError>
-
@Christian-Ehrlicher , thank you, I didn't think the header was required as the type was auto completed when I typed it in, but that has indeed fixed the problem.