Calling 'lastError' with incomplete return type 'QSqlError'
-
I cannot wrap my head around this simple issue. I am working with MYSQL on QT and just trying to connect to my database that is running on the virtual machine. I use the following:
void MainWindow::ConnectToDB(){ QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("192.168.3.146"); db.setPort(20080); db.setDatabaseName("test"); db.setUserName("name"); db.setPassword("password"); bool ok = db.open(); qDebug("DB open state = %u ",ok); if(ok == 0){ qDebug("error = %s",db.lastError().text()); } }I cannot print lastError() as it is giving me error:
error: Calling 'lastError' with incomplete return type 'QSqlError'I have found other simmillar forum posts:
https://www.qtcentre.org/threads/51484-QSqlDatabase-lastError()-in-MessageBoxBut this does not seem to fix my issue.
I think its something silly but I cannot figure it out. Thanks in advance.!
-
I cannot wrap my head around this simple issue. I am working with MYSQL on QT and just trying to connect to my database that is running on the virtual machine. I use the following:
void MainWindow::ConnectToDB(){ QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setHostName("192.168.3.146"); db.setPort(20080); db.setDatabaseName("test"); db.setUserName("name"); db.setPassword("password"); bool ok = db.open(); qDebug("DB open state = %u ",ok); if(ok == 0){ qDebug("error = %s",db.lastError().text()); } }I cannot print lastError() as it is giving me error:
error: Calling 'lastError' with incomplete return type 'QSqlError'I have found other simmillar forum posts:
https://www.qtcentre.org/threads/51484-QSqlDatabase-lastError()-in-MessageBoxBut this does not seem to fix my issue.
I think its something silly but I cannot figure it out. Thanks in advance.!
@lukutis222
Not sure whether it depends on what version of Qt you have, because I don't particularly recall seeing this issue, but forQSqlErroryou need#include <QSqlError>, and if you only have#include <QSqlDatabase>that may not be enough. -
@lukutis222
Not sure whether it depends on what version of Qt you have, because I don't particularly recall seeing this issue, but forQSqlErroryou need#include <QSqlError>, and if you only have#include <QSqlDatabase>that may not be enough. -
L lukutis222 has marked this topic as solved on