Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QSqlIndex Class Reference

The QSqlIndex class provides functions to manipulate and describe database indexes. More...

#include <qsqlindex.h>

+ Inheritance diagram for QSqlIndex:
+ Collaboration diagram for QSqlIndex:

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.
 
QSqlIndexoperator= (const QSqlIndex &other)
 Move-assigns other to this QSqlIndex instance.
 
void swap (QSqlIndex &other) noexcept
 
void setCursorName (const QString &cursorName)
 Sets \l cursorName to cursorName.
 
QString cursorName () const
 Returns the \l cursorName.
 
void setName (const QString &name)
 Sets \l name to name.
 
QString name () const
 Returns the \l name.
 
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.
 
- Public Member Functions inherited from QSqlRecord
 QSqlRecord ()
 Constructs an empty record.
 
 QSqlRecord (const QSqlRecord &other)
 Constructs a copy of other.
 
 QSqlRecord (QSqlRecord &&other) noexcept=default
 
QSqlRecordoperator= (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.
 
QVariant value (QStringView 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.
 
void setValue (QStringView 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.
 
void setNull (QStringView 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
 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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool isNull (QStringView 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 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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
int indexOf (QStringView 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.
 
QSqlField field (QStringView 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
 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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool isGenerated (QStringView 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 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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void setGenerated (QStringView name, bool generated)
 Sets the generated flag for the field called name to generated.
 
void setGenerated (int i, bool generated)
 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
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool contains (QStringView 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
 

Properties

QString name
 
QString cursorName
 

Detailed Description

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 17 of file qsqlindex.h.

Constructor & Destructor Documentation

◆ QSqlIndex() [1/3]

QSqlIndex::QSqlIndex ( const QString & cursorName = QString(),
const QString & name = QString() )
explicit

Constructs an empty index using the cursor name cursorname and index name name.

Definition at line 30 of file qsqlindex.cpp.

◆ QSqlIndex() [2/3]

QSqlIndex::QSqlIndex ( const QSqlIndex & other)

Constructs a copy of other.

Definition at line 39 of file qsqlindex.cpp.

◆ QSqlIndex() [3/3]

QSqlIndex::QSqlIndex ( QSqlIndex && other)
defaultnoexcept

Move-constructs a new QSqlIndex from other.

Note
The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
Since
6.6

◆ ~QSqlIndex()

QSqlIndex::~QSqlIndex ( )

Destroys the object and frees any allocated resources.

Definition at line 81 of file qsqlindex.cpp.

Member Function Documentation

◆ append() [1/2]

void QSqlIndex::append ( const QSqlField & field)

Appends the field field to the list of indexed fields.

The field is appended with an ascending sort order.

Definition at line 108 of file qsqlindex.cpp.

References append(), and QSqlRecord::field().

Referenced by append(), QSQLiteDriverPrivate::getTableInfo(), QMYSQLDriver::primaryIndex(), QOCIDriver::primaryIndex(), and QPSQLDriver::primaryIndex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [2/2]

void QSqlIndex::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.

The field is appended with an ascending sort order, unless desc is true.

Definition at line 121 of file qsqlindex.cpp.

References QSqlRecord::append(), QList< T >::append(), and QSqlRecord::field().

+ Here is the call graph for this function:

◆ cursorName()

QString QSqlIndex::cursorName ( ) const
inline

Returns the \l cursorName.

Definition at line 39 of file qsqlindex.h.

References cursor.

◆ isDescending()

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 133 of file qsqlindex.cpp.

References i, and QList< T >::size().

+ Here is the call graph for this function:

◆ name()

QString QSqlIndex::name ( ) const
inline

Returns the \l name.

Definition at line 41 of file qsqlindex.h.

◆ operator=()

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

Move-assigns other to this QSqlIndex instance.

Sets the index equal to other.

Note
The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.
Since
6.6

Definition at line 67 of file qsqlindex.cpp.

References QSqlRecord::operator=(), and other().

+ Here is the call graph for this function:

◆ setCursorName()

void QSqlIndex::setCursorName ( const QString & cursorName)

Sets \l cursorName to cursorName.

Definition at line 165 of file qsqlindex.cpp.

References cursorName.

Referenced by QMYSQLDriver::primaryIndex().

+ Here is the caller graph for this function:

◆ setDescending()

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 146 of file qsqlindex.cpp.

References i, and QList< T >::size().

+ Here is the call graph for this function:

◆ setName()

void QSqlIndex::setName ( const QString & name)

Sets \l name to name.

Definition at line 98 of file qsqlindex.cpp.

References name.

Referenced by QMYSQLDriver::primaryIndex(), QOCIDriver::primaryIndex(), and QPSQLDriver::primaryIndex().

+ Here is the caller graph for this function:

◆ swap()

void QSqlIndex::swap ( QSqlIndex & other)
inlinenoexcept

Definition at line 31 of file qsqlindex.h.

References cursor, other(), QCursor::swap(), and QSqlRecord::swap().

+ Here is the call graph for this function:

Property Documentation

◆ cursorName

QSqlIndex::cursorName
readwrite
Since
6.8 This property holds the name of the cursor which the index is associated with.

Definition at line 22 of file qsqlindex.h.

Referenced by setCursorName().

◆ name

QSqlIndex::name
readwrite
Since
6.8 This property holds the name of the index.

Definition at line 21 of file qsqlindex.h.

Referenced by setName().


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