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: Deprecation of old constructor: What do replace it with?
Forum Updated to NodeBB v4.3 + New Features

QSqlError: Deprecation of old constructor: What do replace it with?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 514 Views
  • 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi.
    The following code generates deprecation warnings:

    static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, int errorCode = -1)
    {
        return QSqlError(descr, QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))), type, errorCode);
    }
    
    qsql_sqlite.cpp:106: warning: ‘QSqlError::QSqlError(const QString&, const QString&, QSqlError::ErrorType, int)’ is deprecated [-Wdeprecated-declarations]
                          type, errorCode);
                                         ^
    

    From https://doc.qt.io/qt-5/qsqlerror-obsolete.html, the above constructor is indeed listed as deprecated, and so are all method to set the above arguments separately.

    So what is the correct new way to construct and initialize an QSqlError object?

    JonBJ 1 Reply Last reply
    0
    • JonBJ JonB

      @Diracsbracket
      So look at the documentation: https://doc.qt.io/qt-5/qsqlerror.html#QSqlError-1

      QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString())
      

      You can use this instead.

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #3

      @JonB
      So embarrassing. As usual, I was too blind to see that the error code argument was changed from int to QString.

      Thank you....!

      1 Reply Last reply
      1
      • DiracsbracketD Diracsbracket

        Hi.
        The following code generates deprecation warnings:

        static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::ErrorType type, int errorCode = -1)
        {
            return QSqlError(descr, QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))), type, errorCode);
        }
        
        qsql_sqlite.cpp:106: warning: ‘QSqlError::QSqlError(const QString&, const QString&, QSqlError::ErrorType, int)’ is deprecated [-Wdeprecated-declarations]
                              type, errorCode);
                                             ^
        

        From https://doc.qt.io/qt-5/qsqlerror-obsolete.html, the above constructor is indeed listed as deprecated, and so are all method to set the above arguments separately.

        So what is the correct new way to construct and initialize an QSqlError object?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @Diracsbracket
        So look at the documentation: https://doc.qt.io/qt-5/qsqlerror.html#QSqlError-1

        QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString())
        

        You can use this instead.

        DiracsbracketD 1 Reply Last reply
        2
        • JonBJ JonB

          @Diracsbracket
          So look at the documentation: https://doc.qt.io/qt-5/qsqlerror.html#QSqlError-1

          QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString())
          

          You can use this instead.

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by
          #3

          @JonB
          So embarrassing. As usual, I was too blind to see that the error code argument was changed from int to QString.

          Thank you....!

          1 Reply Last reply
          1

          • Login

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