diff options
Diffstat (limited to 'src/sql/kernel/qsqlquery.cpp')
-rw-r--r-- | src/sql/kernel/qsqlquery.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index eff211cc37..07b23f7f03 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -406,6 +406,24 @@ QVariant QSqlQuery::value(int index) const } /*! + \overload + + Returns the value of the field called \a name in the current record. + If field \a name does not exist an invalid variant is returned. + + This overload is less efficient than \l{QSqlQuery::}{value()} +*/ + +QVariant QSqlQuery::value(const QString& name) const +{ + int index = d->sqlResult->record().indexOf(name); + if (index > -1) + return value(index); + qWarning("QSqlQuery::value: unknown field name '%s'", qPrintable(name)); + return QVariant(); +} + +/*! Returns the current internal position of the query. The first record is at position zero. If the position is invalid, the function returns QSql::BeforeFirstRow or |