Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlError, variable has incomplete type 'const QSqlError' ?

QSqlError, variable has incomplete type 'const QSqlError' ?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    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?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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>

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @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.

        Kind Regards,
        Sy

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved