Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 (QAnyStringView 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 18 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 31 of file qsqlindex.cpp.

◆ QSqlIndex() [2/3]

QSqlIndex::QSqlIndex ( const QSqlIndex & other)

Constructs a copy of other.

Definition at line 40 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 82 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 109 of file qsqlindex.cpp.

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

◆ cursorName()

QString QSqlIndex::cursorName ( ) const
inline

Returns the \l cursorName.

Definition at line 40 of file qsqlindex.h.

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

◆ name()

QString QSqlIndex::name ( ) const
inline

Returns the \l name.

Definition at line 42 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 68 of file qsqlindex.cpp.

◆ setCursorName()

void QSqlIndex::setCursorName ( const QString & cursorName)

Sets \l cursorName to cursorName.

Definition at line 166 of file qsqlindex.cpp.

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

◆ setName()

void QSqlIndex::setName ( const QString & name)

Sets \l name to name.

Definition at line 99 of file qsqlindex.cpp.

◆ swap()

void QSqlIndex::swap ( QSqlIndex & other)
inlinenoexcept

Definition at line 32 of file qsqlindex.h.

Property Documentation

◆ cursorName

QString 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.

◆ name

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

Definition at line 21 of file qsqlindex.h.

Referenced by testing.tools.encode_pdf_filter._PdfStream::RegisterByName().


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