![]() |
Qt 6.x
The Qt SDK
|
The QSqlIndex class provides functions to manipulate and describe database indexes. More...
#include <qsqlindex.h>
Public Member Functions | |
QSqlIndex (const QString &cursorName=QString(), const QString &name=QString()) | |
Constructs an empty index using the cursor name cursorname and index name name. | |
QSqlIndex (const QSqlIndex &other) | |
Constructs a copy of other. | |
QSqlIndex (QSqlIndex &&other) noexcept=default | |
Move-constructs a new QSqlIndex from other. | |
~QSqlIndex () | |
Destroys the object and frees any allocated resources. | |
QSqlIndex & | operator= (const QSqlIndex &other) |
Sets the index equal to other. | |
QSqlIndex & | operator= (QSqlIndex &&other)=default |
Move-assigns other to this QSqlIndex instance. | |
void | setCursorName (const QString &cursorName) |
Sets the name of the cursor that the index is associated with to cursorName. | |
QString | cursorName () const |
Returns the name of the cursor which the index is associated with. | |
void | setName (const QString &name) |
Sets the name of the index to name. | |
QString | name () const |
Returns the name of the index. | |
void | append (const QSqlField &field) |
Appends the field field to the list of indexed fields. | |
void | append (const QSqlField &field, bool desc) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends the field field to the list of indexed fields. | |
bool | isDescending (int i) const |
Returns true if field i in the index is sorted in descending order; otherwise returns false . | |
void | setDescending (int i, bool desc) |
If desc is true, field i is sorted in descending order. | |
![]() | |
QSqlRecord () | |
Constructs an empty record. | |
QSqlRecord (const QSqlRecord &other) | |
Constructs a copy of other. | |
QSqlRecord (QSqlRecord &&other) noexcept=default | |
QSqlRecord & | operator= (const QSqlRecord &other) |
Sets the record equal to other. | |
~QSqlRecord () | |
Destroys the object and frees any allocated resources. | |
void | swap (QSqlRecord &other) noexcept |
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 . | |
bool | operator!= (const QSqlRecord &other) const |
Returns true if this object is not identical to other; otherwise returns false . | |
QVariant | value (int i) const |
Returns the value of the field located at position index in the record. | |
QVariant | value (const QString &name) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the value of the field called name in the record. | |
void | setValue (int i, const QVariant &val) |
Sets the value of the field at position index to val. | |
void | setValue (const QString &name, const QVariant &val) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the value of the field called name to val. | |
void | setNull (int i) |
Sets the value of field index to null. | |
void | setNull (const QString &name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the value of the field called name to null. | |
bool | isNull (int i) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the field index is null or if there is no field at position index; otherwise returns false . | |
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 . | |
int | indexOf (const QString &name) const |
Returns the position of the field called name within the record, or -1 if it cannot be found. | |
QString | fieldName (int i) const |
Returns the name of the field at position index. | |
QSqlField | field (int i) const |
Returns the field at position index. | |
QSqlField | field (const QString &name) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the field called name. | |
bool | isGenerated (int i) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the record has a field at position index and this field is to be generated (the default); otherwise returns false . | |
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 . | |
void | setGenerated (const QString &name, bool generated) |
Sets the generated flag for the field called name to generated. | |
void | setGenerated (int i, bool generated) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the generated flag for the field index to generated. | |
void | append (const QSqlField &field) |
Append a copy of field field to the end of the record. | |
void | replace (int pos, const QSqlField &field) |
Replaces the field at position pos with the given field. | |
void | insert (int pos, const QSqlField &field) |
Inserts the field field at position pos in the record. | |
void | remove (int pos) |
Removes the field at position pos. | |
bool | isEmpty () const |
Returns true if there are no fields in the record; otherwise returns false . | |
bool | contains (const QString &name) const |
Returns true if there is a field in the record called name; otherwise returns false . | |
void | clear () |
Removes all the record's fields. | |
void | clearValues () |
Clears the value of all fields in the record and sets each field to null. | |
int | count () const |
Returns the number of fields in the record. | |
QSqlRecord | keyValues (const QSqlRecord &keyFields) const |
The QSqlIndex class provides functions to manipulate and describe database indexes.
\inmodule QtSql
An index refers to a single table or view in a database. Information about the fields that comprise the index can be used to generate SQL statements.
Definition at line 15 of file qsqlindex.h.
|
explicit |
Constructs an empty index using the cursor name cursorname and index name name.
Definition at line 30 of file qsqlindex.cpp.
QSqlIndex::QSqlIndex | ( | const QSqlIndex & | other | ) |
Constructs a copy of other.
Definition at line 39 of file qsqlindex.cpp.
|
defaultnoexcept |
Move-constructs a new QSqlIndex from other.
QSqlIndex::~QSqlIndex | ( | ) |
Destroys the object and frees any allocated resources.
Definition at line 81 of file qsqlindex.cpp.
Appends the field field to the list of indexed fields.
The field is appended with an ascending sort order.
Definition at line 106 of file qsqlindex.cpp.
References append(), and QSqlRecord::field().
Referenced by append(), QMYSQLDriver::primaryIndex(), QOCIDriver::primaryIndex(), QPSQLDriver::primaryIndex(), and qGetTableInfo().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends the field field to the list of indexed fields.
The field is appended with an ascending sort order, unless desc is true.
Definition at line 119 of file qsqlindex.cpp.
References QSqlRecord::append(), QList< T >::append(), desc, and QSqlRecord::field().
|
inline |
Returns the name of the cursor which the index is associated with.
Definition at line 26 of file qsqlindex.h.
References cursor.
Referenced by setCursorName().
bool QSqlIndex::isDescending | ( | int | i | ) | const |
Returns true
if field i in the index is sorted in descending order; otherwise returns false
.
Definition at line 131 of file qsqlindex.cpp.
References i, and QList< T >::size().
|
inline |
Returns the name of the index.
Definition at line 28 of file qsqlindex.h.
Referenced by setName().
Sets the index equal to other.
Definition at line 67 of file qsqlindex.cpp.
References QSqlRecord::operator=(), and other().
Move-assigns other to this QSqlIndex instance.
Sets the name of the cursor that the index is associated with to cursorName.
Definition at line 179 of file qsqlindex.cpp.
References cursorName().
Referenced by QMYSQLDriver::primaryIndex().
void QSqlIndex::setDescending | ( | int | i, |
bool | desc | ||
) |
If desc is true, field i is sorted in descending order.
Otherwise, field i is sorted in ascending order (the default). If the field does not exist, nothing happens.
Definition at line 144 of file qsqlindex.cpp.
References desc, i, and QList< T >::size().
Sets the name of the index to name.
Definition at line 90 of file qsqlindex.cpp.
References name().
Referenced by QMYSQLDriver::primaryIndex(), QOCIDriver::primaryIndex(), and QPSQLDriver::primaryIndex().