Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QSqlRecord Class Reference

The QSqlRecord class encapsulates a database record. More...

#include <qsqlrecord.h>

Inheritance diagram for QSqlRecord:
QSqlIndex

Public Functions

void append (const QSqlField &field)
 Append a copy of field field to the end of the record. More...
 
void clear ()
 Removes all the record's fields. More...
 
void clearValues ()
 Clears the value of all fields in the record and sets each field to null. More...
 
bool contains (const QString &name) const
 Returns true if there is a field in the record called name; otherwise returns false. More...
 
int count () const
 Returns the number of fields in the record. More...
 
QSqlField field (int i) const
 Returns the field at position index. More...
 
QSqlField field (const QString &name) const
 Returns the field called name. More...
 
QString fieldName (int i) const
 Returns the name of the field at position index. More...
 
int indexOf (const QString &name) const
 Returns the position of the field called name within the record, or -1 if it cannot be found. More...
 
void insert (int pos, const QSqlField &field)
 Inserts the field field at position pos in the record. More...
 
bool isEmpty () const
 Returns true if there are no fields in the record; otherwise returns false. More...
 
bool isGenerated (int i) const
 Returns true if the record has a field at position index and this field is to be generated (the default); otherwise returns false. More...
 
bool isGenerated (const QString &name) const
 Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false. More...
 
bool isNull (int i) const
 Returns true if the field index is null or if there is no field at position index; otherwise returns false. More...
 
bool isNull (const QString &name) const
 Returns true if the field called name is null or if there is no field called name; otherwise returns false. More...
 
bool operator!= (const QSqlRecord &other) const
 Returns true if this object is not identical to other; otherwise returns false. More...
 
QSqlRecordoperator= (const QSqlRecord &other)
 Sets the record equal to other. More...
 
bool operator== (const QSqlRecord &other) const
 Returns true if this object is identical to other (i.e., has the same fields in the same order); otherwise returns false. More...
 
 QSqlRecord ()
 Constructs an empty record. More...
 
 QSqlRecord (const QSqlRecord &other)
 Constructs a copy of other. More...
 
void remove (int pos)
 Removes the field at position pos. More...
 
void replace (int pos, const QSqlField &field)
 Replaces the field at position pos with the given field. More...
 
void setGenerated (const QString &name, bool generated)
 Sets the generated flag for the field called name to generated. More...
 
void setGenerated (int i, bool generated)
 Sets the generated flag for the field index to generated. More...
 
void setNull (int i)
 Sets the value of field index to null. More...
 
void setNull (const QString &name)
 Sets the value of the field called name to null. More...
 
void setValue (int i, const QVariant &val)
 Sets the value of the field at position index to val. More...
 
void setValue (const QString &name, const QVariant &val)
 Sets the value of the field called name to val. More...
 
QVariant value (int i) const
 Returns the value of the field located at position index in the record. More...
 
QVariant value (const QString &name) const
 Returns the value of the field called name in the record. More...
 
 ~QSqlRecord ()
 Destroys the object and frees any allocated resources. More...
 

Private Functions

void detach ()
 

Properties

QSqlRecordPrivated
 

Detailed Description

The QSqlRecord class encapsulates a database record.

Attention
Module: QtSql

The QSqlRecord class encapsulates the functionality and characteristics of a database record (usually a row in a table or view within the database). QSqlRecord supports adding and removing fields as well as setting and retrieving field values.

The values of a record's fields' can be set by name or position with setValue(); if you want to set a field to null use setNull(). To find the position of a field by name use indexOf(), and to find the name of a field at a particular position use fieldName(). Use field() to retrieve a QSqlField object for a given field. Use contains() to see if the record contains a particular field name.

When queries are generated to be executed on the database only those fields for which isGenerated() is true are included in the generated SQL.

A record can have fields added with append() or insert(), replaced with replace(), and removed with remove(). All the fields can be removed with clear(). The number of fields is given by count(); all their values can be cleared (to null) using clearValues().

See also
QSqlField, QSqlQuery::record()

Definition at line 58 of file qsqlrecord.h.

Constructors and Destructors

◆ QSqlRecord() [1/2]

QSqlRecord::QSqlRecord ( )

Constructs an empty record.

See also
isEmpty(), append(), insert()

Definition at line 131 of file qsqlrecord.cpp.

132 {
133  d = new QSqlRecordPrivate();
134 }
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ QSqlRecord() [2/2]

QSqlRecord::QSqlRecord ( const QSqlRecord other)

Constructs a copy of other.

QSqlRecord is implicitly shared. This means you can make copies of a record in constant time.

Definition at line 143 of file qsqlrecord.cpp.

144 {
145  d = other.d;
146  d->ref.ref();
147 }
bool ref()
Atomically increments the value of this QAtomicInt.
QAtomicInt ref
Definition: qsqlrecord.cpp:63
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ ~QSqlRecord()

QSqlRecord::~QSqlRecord ( )

Destroys the object and frees any allocated resources.

Definition at line 166 of file qsqlrecord.cpp.

167 {
168  if (!d->ref.deref())
169  delete d;
170 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QAtomicInt ref
Definition: qsqlrecord.cpp:63
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

Functions

◆ append()

void QSqlRecord::append ( const QSqlField field)

◆ clear()

void QSqlRecord::clear ( void  )

Removes all the record's fields.

See also
clearValues() isEmpty()

Definition at line 367 of file qsqlrecord.cpp.

Referenced by QTDSResult::cleanup(), QSQLite2ResultPrivate::cleanup(), QSQLiteResultPrivate::cleanup(), QSqlTableModelPrivate::clear(), QDB2Result::exec(), QSQLiteResult::exec(), QODBCResult::exec(), QSQLite2ResultPrivate::init(), QDB2Result::nextResult(), QODBCResult::nextResult(), QDB2Result::prepare(), QODBCResult::prepare(), QDB2Result::reset(), and QODBCResult::reset().

368 {
369  detach();
370  d->fields.clear();
371 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ clearValues()

void QSqlRecord::clearValues ( )

Clears the value of all fields in the record and sets each field to null.

See also
setValue()

Definition at line 403 of file qsqlrecord.cpp.

404 {
405  detach();
406  int count = d->fields.count();
407  for (int i = 0; i < count; ++i)
408  d->fields[i].clear();
409 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
int count() const
Returns the number of fields in the record.
Definition: qsqlrecord.cpp:573
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ contains()

bool QSqlRecord::contains ( const QString name) const

Returns true if there is a field in the record called name; otherwise returns false.

Definition at line 391 of file qsqlrecord.cpp.

Referenced by QSQLite2Driver::primaryIndex().

392 {
393  return indexOf(name) >= 0;
394 }
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ count()

int QSqlRecord::count ( ) const

◆ detach()

void QSqlRecord::detach ( )
private
Warning
This function is not part of the public interface.

Definition at line 612 of file qsqlrecord.cpp.

613 {
614  qAtomicDetach(d);
615 }
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
Definition: qatomic.h:214
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ field() [1/2]

QSqlField QSqlRecord::field ( int  index) const

Returns the field at position index.

If the index is out of range, function returns a default-constructed value.

Definition at line 289 of file qsqlrecord.cpp.

Referenced by QSqlIndex::createField(), QDB2Result::data(), QODBCResult::data(), QTDSResult::gotoNext(), operator<<(), QRelation::populateDictionary(), QDB2Driver::primaryIndex(), QSQLite2Driver::primaryIndex(), QTDSDriver::primaryIndex(), QMYSQLDriver::primaryIndex(), QODBCDriver::primaryIndex(), and QSqlDriver::sqlStatement().

290 {
291  return d->fields.value(index);
292 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ field() [2/2]

QSqlField QSqlRecord::field ( const QString name) const

Returns the field called name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 300 of file qsqlrecord.cpp.

301 {
302  return field(indexOf(name));
303 }
QSqlField field(int i) const
Returns the field at position index.
Definition: qsqlrecord.cpp:289
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ fieldName()

QString QSqlRecord::fieldName ( int  index) const

Returns the name of the field at position index.

If the field does not exist, an empty string is returned.

See also
indexOf()

Definition at line 232 of file qsqlrecord.cpp.

Referenced by QSqlTableModelPrivate::primaryValues(), qmlsqldatabase_item(), QSqlRelationalTableModel::selectStatement(), QSqlTableModelPrivate::setRecord(), QSqlTableModel::setRecord(), and QSqlDriver::sqlStatement().

233 {
234  return d->fields.value(index).name();
235 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
QString name() const
Returns the name of the field.
Definition: qsqlfield.cpp:380
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ indexOf()

int QSqlRecord::indexOf ( const QString name) const

Returns the position of the field called name within the record, or -1 if it cannot be found.

Field names are not case-sensitive. If more than one field matches, the first one is returned.

See also
fieldName()

Definition at line 246 of file qsqlrecord.cpp.

Referenced by QSqlTableModelPrivate::nameToIndex(), QSqlTableModelPrivate::primaryValues(), and QSqlTableModel::setRecord().

247 {
248  QString nm = name.toUpper();
249  for (int i = 0; i < count(); ++i) {
250  if (d->fields.at(i).name().toUpper() == nm) // TODO: case-insensitive comparison
251  return i;
252  }
253  return -1;
254 }
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
The QString class provides a Unicode character string.
Definition: qstring.h:83
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
QString name() const
Returns the name of the field.
Definition: qsqlfield.cpp:380
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
int count() const
Returns the number of fields in the record.
Definition: qsqlrecord.cpp:573
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ insert()

void QSqlRecord::insert ( int  pos,
const QSqlField field 
)

Inserts the field field at position pos in the record.

See also
append() replace() remove()

Definition at line 323 of file qsqlrecord.cpp.

324 {
325  detach();
326  d->fields.insert(pos, field);
327 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ isEmpty()

bool QSqlRecord::isEmpty ( ) const

Returns true if there are no fields in the record; otherwise returns false.

See also
append() insert() clear()

Definition at line 380 of file qsqlrecord.cpp.

Referenced by QSQLiteResult::exec(), QSQLite2ResultPrivate::fetchNext(), QSQLiteResultPrivate::fetchNext(), QSqlTableModelPrivate::primaryValues(), and QSQLite2Result::reset().

381 {
382  return d->fields.isEmpty();
383 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ isGenerated() [1/2]

bool QSqlRecord::isGenerated ( int  index) const

Returns true if the record has a field at position index and this field is to be generated (the default); otherwise returns false.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
setGenerated()

Definition at line 519 of file qsqlrecord.cpp.

Referenced by QSqlTableModel::data(), QSqlRelationalTableModel::data(), QSqlTableModelPrivate::exec(), QSqlTableModel::isDirty(), QSqlTableModelPrivate::setRecord(), QSqlTableModel::setRecord(), QSqlDriver::sqlStatement(), and QSqlRelationalTableModelPrivate::translateFieldNames().

520 {
521  return d->fields.value(index).isGenerated();
522 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112
bool isGenerated() const
Returns true if the field is generated; otherwise returns false.
Definition: qsqlfield.cpp:508

◆ isGenerated() [2/2]

bool QSqlRecord::isGenerated ( const QString name) const

Returns true if the record has a field called name and this field is to be generated (the default); otherwise returns false.

See also
setGenerated()

Definition at line 504 of file qsqlrecord.cpp.

505 {
506  return isGenerated(indexOf(name));
507 }
bool isGenerated(int i) const
Returns true if the record has a field at position index and this field is to be generated (the defau...
Definition: qsqlrecord.cpp:519
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ isNull() [1/2]

bool QSqlRecord::isNull ( int  index) const

Returns true if the field index is null or if there is no field at position index; otherwise returns false.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 453 of file qsqlrecord.cpp.

Referenced by QSqlTableModelPrivate::exec(), and QSqlDriver::sqlStatement().

454 {
455  return d->fields.value(index).isNull();
456 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
bool isNull() const
Returns true if the field&#39;s value is NULL; otherwise returns false.
Definition: qsqlfield.cpp:428
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ isNull() [2/2]

bool QSqlRecord::isNull ( const QString name) const

Returns true if the field called name is null or if there is no field called name; otherwise returns false.

See also
setNull()

Definition at line 464 of file qsqlrecord.cpp.

465 {
466  return isNull(indexOf(name));
467 }
bool isNull(int i) const
Returns true if the field index is null or if there is no field at position index; otherwise returns ...
Definition: qsqlrecord.cpp:453
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ operator!=()

bool QSqlRecord::operator!= ( const QSqlRecord other) const
inline

Returns true if this object is not identical to other; otherwise returns false.

See also
operator==()

Definition at line 67 of file qsqlrecord.h.

67 { return !operator==(other); }
bool operator==(const QSqlRecord &other) const
Returns true if this object is identical to other (i.e., has the same fields in the same order); othe...
Definition: qsqlrecord.cpp:190

◆ operator=()

QSqlRecord & QSqlRecord::operator= ( const QSqlRecord other)

Sets the record equal to other.

QSqlRecord is implicitly shared. This means you can make copies of a record in constant time.

Definition at line 156 of file qsqlrecord.cpp.

Referenced by QSqlIndex::operator=().

157 {
158  qAtomicAssign(d, other.d);
159  return *this;
160 }
void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
Definition: qatomic.h:195
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ operator==()

bool QSqlRecord::operator== ( const QSqlRecord other) const

Returns true if this object is identical to other (i.e., has the same fields in the same order); otherwise returns false.

See also
operator!=()

Definition at line 190 of file qsqlrecord.cpp.

191 {
192  return d->fields == other.d->fields;
193 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ remove()

void QSqlRecord::remove ( int  pos)

Removes the field at position pos.

If pos is out of range, nothing happens.

See also
append() insert() replace()

Definition at line 352 of file qsqlrecord.cpp.

353 {
354  if (!d->contains(pos))
355  return;
356 
357  detach();
358  d->fields.remove(pos);
359 }
void remove(int i)
Removes the element at index position i.
Definition: qvector.h:374
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
bool contains(int index)
Definition: qsqlrecord.cpp:59
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ replace()

void QSqlRecord::replace ( int  pos,
const QSqlField field 
)

Replaces the field at position pos with the given field.

If pos is out of range, nothing happens.

See also
append() insert() remove()

Definition at line 336 of file qsqlrecord.cpp.

Referenced by QSqlRelationalTableModelPrivate::translateFieldNames().

337 {
338  if (!d->contains(pos))
339  return;
340 
341  detach();
342  d->fields[pos] = field;
343 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
QSqlField field(int i) const
Returns the field at position index.
Definition: qsqlrecord.cpp:289
bool contains(int index)
Definition: qsqlrecord.cpp:59
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ setGenerated() [1/2]

void QSqlRecord::setGenerated ( const QString name,
bool  generated 
)

Sets the generated flag for the field called name to generated.

If the field does not exist, nothing happens. Only fields that have generated set to true are included in the SQL that is generated by QSqlQueryModel for example.

See also
isGenerated()

Definition at line 420 of file qsqlrecord.cpp.

Referenced by QSqlTableModelPrivate::clearGenerated(), QSqlTableModelPrivate::setGeneratedValue(), QSqlTableModel::setRecord(), and QSqlRelationalTableModelPrivate::translateFieldNames().

421 {
422  setGenerated(indexOf(name), generated);
423 }
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246
void setGenerated(const QString &name, bool generated)
Sets the generated flag for the field called name to generated.
Definition: qsqlrecord.cpp:420

◆ setGenerated() [2/2]

void QSqlRecord::setGenerated ( int  index,
bool  generated 
)

Sets the generated flag for the field index to generated.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
isGenerated()

Definition at line 436 of file qsqlrecord.cpp.

437 {
438  if (!d->contains(index))
439  return;
440  detach();
441  d->fields[index].setGenerated(generated);
442 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
bool contains(int index)
Definition: qsqlrecord.cpp:59
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ setNull() [1/2]

void QSqlRecord::setNull ( int  index)

Sets the value of field index to null.

If the field does not exist, nothing happens.

See also
setValue()

Definition at line 475 of file qsqlrecord.cpp.

476 {
477  if (!d->contains(index))
478  return;
479  detach();
480  d->fields[index].clear();
481 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
bool contains(int index)
Definition: qsqlrecord.cpp:59
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ setNull() [2/2]

void QSqlRecord::setNull ( const QString name)

Sets the value of the field called name to null.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If the field does not exist, nothing happens.

Definition at line 492 of file qsqlrecord.cpp.

493 {
494  setNull(indexOf(name));
495 }
void setNull(int i)
Sets the value of field index to null.
Definition: qsqlrecord.cpp:475
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ setValue() [1/2]

void QSqlRecord::setValue ( int  index,
const QVariant val 
)

Sets the value of the field at position index to val.

If the field does not exist, nothing happens.

See also
setNull()

Definition at line 585 of file qsqlrecord.cpp.

Referenced by QSqlTableModelPrivate::primaryValues(), QSqlQueryModel::record(), QSqlTableModelPrivate::record(), QSqlQuery::record(), QSqlTableModelPrivate::setGeneratedValue(), QSqlTableModel::setRecord(), and QSqlRelationalTableModelPrivate::translateFieldNames().

586 {
587  if (!d->contains(index))
588  return;
589  detach();
590  d->fields[index].setValue(val);
591 }
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
void detach()
Definition: qsqlrecord.cpp:612
bool contains(int index)
Definition: qsqlrecord.cpp:59
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ setValue() [2/2]

void QSqlRecord::setValue ( const QString name,
const QVariant val 
)

Sets the value of the field called name to val.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If the field does not exist, nothing happens.

Definition at line 604 of file qsqlrecord.cpp.

605 {
606  setValue(indexOf(name), val);
607 }
void setValue(int i, const QVariant &val)
Sets the value of the field at position index to val.
Definition: qsqlrecord.cpp:585
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246

◆ value() [1/2]

QVariant QSqlRecord::value ( int  index) const

Returns the value of the field located at position index in the record.

If index is out of bounds, an invalid QVariant is returned.

See also
fieldName() isNull()

Definition at line 203 of file qsqlrecord.cpp.

Referenced by QSqlTableModel::data(), QSqlRelationalTableModel::data(), QSqlTableModelPrivate::exec(), operator<<(), qmlsqldatabase_item(), QSqlTableModelPrivate::setRecord(), QSqlTableModel::setRecord(), and QSqlRelationalTableModelPrivate::translateFieldNames().

204 {
205  return d->fields.value(index).value();
206 }
QVariant value() const
Returns the value of the field as a QVariant.
Definition: qsqlfield.h:71
QVector< QSqlField > fields
Definition: qsqlrecord.cpp:62
T value(int i) const
Returns the value at index position i in the vector.
Definition: qvector.h:559
quint16 index
QSqlRecordPrivate * d
Definition: qsqlrecord.h:112

◆ value() [2/2]

QVariant QSqlRecord::value ( const QString name) const

Returns the value of the field called name in the record.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If field name does not exist an invalid variant is returned.

See also
indexOf()

Definition at line 220 of file qsqlrecord.cpp.

221 {
222  return value(indexOf(name));
223 }
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found...
Definition: qsqlrecord.cpp:246
QVariant value(int i) const
Returns the value of the field located at position index in the record.
Definition: qsqlrecord.cpp:203

Properties

◆ d

QSqlRecordPrivate* QSqlRecord::d
private

Definition at line 112 of file qsqlrecord.h.

Referenced by operator=(), operator==(), and QSqlRecord().


The documentation for this class was generated from the following files: