QSqlError: Deprecation of old constructor: What do replace it with?
Solved
General and Desktop
-
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? -
@Diracsbracket
So look at the documentation: https://doc.qt.io/qt-5/qsqlerror.html#QSqlError-1QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &code = QString())
You can use this instead.