QSqlIndex Class

QSqlIndex 类提供了操作和描述数据库索引的函数。更多

头文件: #include <QSqlIndex>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
qmake: QT += sql
继承: QSqlRecord

属性

公共功能

QSqlIndex(const QString &cursorname = QString(), const QString &name = QString())
QSqlIndex(const QSqlIndex &other)
(since 6.6) QSqlIndex(QSqlIndex &&other)
~QSqlIndex()
void append(const QSqlField &field)
void append(const QSqlField &field, bool desc)
QString cursorName() const
bool isDescending(int i) const
QString name() const
void setCursorName(const QString &cursorName)
void setDescending(int i, bool desc)
void setName(const QString &name)
(since 6.6) QSqlIndex &operator=(QSqlIndex &&other)
QSqlIndex &operator=(const QSqlIndex &other)

详细说明

索引指的是数据库中的单个表或视图。组成索引的字段信息可用于生成 SQL 语句。

属性文档

[since 6.8] cursorName : QString

该属性包含与索引相关联的游标的名称。

该属性在 Qt 6.8 中引入。

访问函数:

QString cursorName() const
void setCursorName(const QString &cursorName)

[since 6.8] name : QString

该属性包含索引的名称。

该属性在 Qt 6.8 中引入。

访问函数:

QString name() const
void setName(const QString &name)

成员函数文档

[explicit] QSqlIndex::QSqlIndex(const QString &cursorname = QString(), const QString &name = QString())

使用游标名称cursorname 和索引名称name 构建空索引。

QSqlIndex::QSqlIndex(const QSqlIndex &other)

构造other 的副本。

[noexcept, since 6.6] QSqlIndex::QSqlIndex(QSqlIndex &&other)

移动-从other 构建一个新的 QSqlIndex。

注意: moved-from 对象other 处于部分形成状态,其中唯一有效的操作是销毁和分配新值。

此函数在 Qt 6.6 中引入。

[noexcept] QSqlIndex::~QSqlIndex()

销毁对象并释放已分配的资源。

void QSqlIndex::append(const QSqlField &field)

将字段field 添加到索引字段列表中。字段以升序排列。

void QSqlIndex::append(const QSqlField &field, bool desc)

这是一个重载函数。

将字段field 附加到索引字段列表中。除非desc 为 true,否则字段将按升序排列。

QString QSqlIndex::cursorName() const

返回游标名称。

注: 属性 cursorName 的获取函数。

另请参阅 setCursorName().

bool QSqlIndex::isDescending(int i) const

如果索引中的字段i 按降序排序,则返回true ;否则返回false

QString QSqlIndex::name() const

返回名称。

注: 属性名称的获取函数。

另请参阅 setName().

void QSqlIndex::setCursorName(const QString &cursorName)

cursorName 设置为cursorName

注: 属性cursorName 的设置函数。

另请参阅 cursorName() 。

void QSqlIndex::setDescending(int i, bool desc)

如果desc 为 true,则字段i 按降序排序。否则,字段i 将按升序排序(默认值)。如果字段不存在,则什么也不会发生。

另请参阅 isDescending() 。

void QSqlIndex::setName(const QString &name)

name 设置为name

注: 属性name 的设置函数。

另请参阅 name() 。

[noexcept, since 6.6] QSqlIndex &QSqlIndex::operator=(QSqlIndex &&other)

移动--将other 赋值给此QSqlIndex 实例。

注意: moved-from 对象other 处于部分形成状态,其中唯一有效的操作是销毁和赋新值。

此函数在 Qt 6.6 中引入。

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

设置索引等于other

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.