Showing preview only (1,610K chars total). Download the full file or copy to clipboard to get everything.
Repository: QtDocumentCN/QtDocumentCN
Branch: master
Commit: 7e6457075123
Files: 132
Total size: 1.5 MB
Directory structure:
gitextract_hmtc6ynp/
├── .github/
│ └── ISSUE_TEMPLATE/
│ └── ----.md
├── Book/
│ ├── book/
│ │ └── .nojekyll
│ ├── book.toml
│ └── src/
│ ├── BookInfo.md
│ └── SUMMARY.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Comparison_Table.md
├── Grammar_Tips.md
├── LICENSE
├── Logo/
│ └── README.md
├── README.md
├── Src/
│ ├── A/
│ │ ├── API_Design_Principles/
│ │ │ └── API_Design_Principles.md
│ │ ├── QAbstractAnimation/
│ │ │ └── QAbstractAnimation.md
│ │ ├── QAbstractAudioDeviceInfo/
│ │ │ └── QAbstractAudioDeviceInfo.md
│ │ ├── QAbstractAudioInput/
│ │ │ └── QAbstractAudioInput.md
│ │ ├── QAbstractAudioOutput/
│ │ │ └── QAbstractAudioOutput.md
│ │ ├── QAbstractAxis/
│ │ │ └── QAbstractAxis.md
│ │ ├── QAbstractBarSeries/
│ │ │ └── QAbstractBarSeries.md
│ │ ├── QAbstractItemModel/
│ │ │ └── QAbstractItemModel.md
│ │ ├── QAbstractItemView/
│ │ │ └── QAbstractItemView.md
│ │ ├── QAbstractSocket/
│ │ │ └── QAbstractSocket.md
│ │ └── QAction/
│ │ └── QAction.md
│ ├── B/
│ │ └── Best_Practice_Guides/
│ │ └── Best_Practice_Guides.md
│ ├── C/
│ │ ├── Container_Classes/
│ │ │ └── Container_Classes.md
│ │ ├── QCheckBox/
│ │ │ └── QCheckBox.md
│ │ ├── QComboBox/
│ │ │ └── QComboBox.md
│ │ └── QCoreApplication/
│ │ └── QCoreApplication.md
│ ├── D/
│ │ └── QDate/
│ │ └── QDate.md
│ ├── F/
│ │ ├── QFile/
│ │ │ └── QFile.md
│ │ └── QFileInfo/
│ │ ├── QFileInfo.md
│ │ ├── qfileinfo-members.md
│ │ └── qfileinfo-obsolete.md
│ ├── G/
│ │ ├── QGenericArgument/
│ │ │ └── QGenericArgument.md
│ │ ├── QGenericReturnArgument/
│ │ │ └── QGenericReturnArgument.md
│ │ └── QtGlobal/
│ │ └── QtGlobal.md
│ ├── H/
│ │ ├── QHash/
│ │ │ ├── QHash-const-iterator.md
│ │ │ ├── QHash-iterator.md
│ │ │ ├── QHash-key-iterator.md
│ │ │ └── QHash.md
│ │ └── QHashIterator/
│ │ └── QHashIterator.md
│ ├── I/
│ │ └── QIODevice/
│ │ └── QIODevice.md
│ ├── J/
│ │ ├── QJsonArray/
│ │ │ └── QJsonArray.md
│ │ ├── QJsonDocument/
│ │ │ └── QJsonDocument.md
│ │ ├── QJsonObject/
│ │ │ └── QJsonObject.md
│ │ ├── QJsonParseError/
│ │ │ └── QJsonParseError.md
│ │ └── QJsonValue/
│ │ └── QJsonValue.md
│ ├── K/
│ │ └── QKeyValueIterator/
│ │ └── QKeyValueIterator.md
│ ├── L/
│ │ ├── QLabel/
│ │ │ └── QLabel.md
│ │ ├── QLibrary/
│ │ │ └── QLibrary.md
│ │ └── QList/
│ │ ├── QList.md
│ │ ├── QListIterator.md
│ │ ├── QList_Const_Iterator.md
│ │ ├── QList_Iterator.md
│ │ └── QMutableListIterator.md
│ ├── M/
│ │ ├── Model_View_Programming/
│ │ │ └── Model_View_Programming.md
│ │ ├── Model_View_Tutorial/
│ │ │ └── Model_View_Tutorial.md
│ │ ├── Multithreading_Technologies_in_Qt/
│ │ │ └── Multithreading_Technologies_in_Qt.md
│ │ ├── QMainWindow/
│ │ │ └── QMainWindow.md
│ │ ├── QMap/
│ │ │ ├── QMap-const-iterator.md
│ │ │ ├── QMap-iterator.md
│ │ │ ├── QMap-key-iterator.md
│ │ │ └── QMap.md
│ │ ├── QMapIterator/
│ │ │ └── QMapIterator.md
│ │ ├── QMetaClassInfo/
│ │ │ └── QMetaClassInfo.md
│ │ ├── QMetaMethod/
│ │ │ └── QMetaMethod.md
│ │ ├── QMetaObject/
│ │ │ ├── QMetaObject.md
│ │ │ └── QMetaObject_Connection.md
│ │ ├── QMetaProperty/
│ │ │ └── QMetaProperty.md
│ │ ├── QMetaType/
│ │ │ └── QMetaType.md
│ │ ├── QMultiHash/
│ │ │ └── QMultiHash.md
│ │ ├── QMultiMap/
│ │ │ └── QMultiMap.md
│ │ ├── QMutableHashIterator/
│ │ │ └── QMutableHashIterator.md
│ │ ├── QMutableMapIterator/
│ │ │ └── QMutableMapIterator.md
│ │ ├── QMutex/
│ │ │ └── QMutex.md
│ │ ├── QMutexLocker/
│ │ │ └── QMutexLocker.md
│ │ ├── The_Meta-Object_System/
│ │ │ └── The_Meta-Object_System.md
│ │ ├── Using_the_Meta-Object_Compiler_moc/
│ │ │ └── Using_the_Meta-Object_Compiler_moc.md
│ │ └── Why_Does_Qt_Use_Moc_for_Signals_and_Slots/
│ │ └── Why_Does_Qt_Use_Moc_for_Signals_and_Slots.md
│ ├── O/
│ │ ├── QObject/
│ │ │ └── QObject.md
│ │ └── QOpenGLShaderProgram/
│ │ └── QOpenGLShaderProgram.md
│ ├── P/
│ │ ├── QPaintDevice/
│ │ │ └── QPaintDevice.md
│ │ ├── QPaintEngine/
│ │ │ └── QPaintEngine.md
│ │ ├── QPainter/
│ │ │ └── QPainter.md
│ │ ├── QPluginLoader/
│ │ │ └── QPluginLoader.md
│ │ ├── QtPlugin/
│ │ │ └── QtPlugin.md
│ │ └── The_Property_System/
│ │ └── The_Property_System.md
│ ├── Q/
│ │ ├── Qt_Namespace/
│ │ │ └── Qt_Namespace.md
│ │ └── Qt_Overviews/
│ │ └── Qt_Overviews.md
│ ├── R/
│ │ ├── QReadLocker/
│ │ │ └── QReadLocker.md
│ │ ├── QReadWriteLock/
│ │ │ └── QReadWriteLock.md
│ │ ├── QRecursiveMutex/
│ │ │ └── QRecursiveMutex.md
│ │ ├── Reentrancy_and_Thread-Safety/
│ │ │ └── Reentrancy_and_Thread-Safety.md
│ │ ├── Resource_Compiler_rcc/
│ │ │ └── Resource_Compiler_rcc.md
│ │ └── The_Qt_Resource_System/
│ │ └── The_Qt_Resource_System.md
│ ├── S/
│ │ ├── QSctpServer/
│ │ │ └── QSctpServer.md
│ │ ├── QSctpSocket/
│ │ │ └── QSctpSocket.md
│ │ ├── QSemaphore/
│ │ │ └── QSemaphore.md
│ │ ├── QSerialPort/
│ │ │ └── QSerialPort.md
│ │ ├── QSerialPortInfo/
│ │ │ └── QSerialPortInfo.md
│ │ ├── QSql/
│ │ │ └── QSql.md
│ │ ├── QSqlDatabase/
│ │ │ └── QSqlDatabase.md
│ │ ├── QSsl/
│ │ │ └── QSsl.md
│ │ ├── QSslCertificate/
│ │ │ └── QSslCertificate.md
│ │ ├── QSslCertificateExtension/
│ │ │ └── QSslCertificateExtension.md
│ │ ├── QSslCertificate_Obsolete/
│ │ │ └── QSslCertificate_Obsolete.md
│ │ ├── QSslCipher/
│ │ │ └── QSslCipher.md
│ │ ├── QSslConfiguration/
│ │ │ └── QSslConfiguration.md
│ │ ├── QSslError/
│ │ │ └── QSslError.md
│ │ ├── QSslKey/
│ │ │ └── QSslKey.md
│ │ ├── QSslSocket/
│ │ │ └── QSslSocket.md
│ │ ├── QSslSocket_Obsolete/
│ │ │ └── QSslSocket_Obsolete.md
│ │ ├── QStyledItemDelegate/
│ │ │ └── QStyledItemDelegate.md
│ │ ├── Signals_and_Slots/
│ │ │ └── Signals_and_Slots.md
│ │ └── Synchronizing_Threads/
│ │ └── Synchronizing_Threads.md
│ ├── T/
│ │ ├── QTcpServer/
│ │ │ └── QTcpServer.md
│ │ ├── QTcpSocket/
│ │ │ └── QTcpSocket.md
│ │ ├── QText2DEntity/
│ │ │ └── QText2DEntity.md
│ │ ├── QTimeLine/
│ │ │ └── QTimeLine.md
│ │ ├── QTimer/
│ │ │ └── QTimer.md
│ │ └── QTransform/
│ │ └── QTransform.md
│ ├── U/
│ │ └── QUdpSocket/
│ │ └── QUdpSocket.md
│ ├── V/
│ │ └── QVariant/
│ │ └── QVariant.md
│ ├── W/
│ │ ├── QWaitCondition/
│ │ │ └── QWaitCondition.md
│ │ ├── QWebEngineHistory/
│ │ │ └── QWebEngineHistory.md
│ │ ├── QWebEngineHistoryItem/
│ │ │ └── QWebEngineHistoryItem.md
│ │ ├── QWebEngineView/
│ │ │ └── QWebEngineView.md
│ │ ├── QWriteLocker/
│ │ │ └── QWriteLocker.md
│ │ └── WebEngine/
│ │ └── QWebEngineView.md
│ └── X/
│ └── QX11Info/
│ └── QX11Info.md
├── Template.md
└── completeness_tracking.md
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/----.md
================================================
---
name: 翻译需求
about: 有需要优先翻译的文档,向社区提出翻译需求
title: ''
labels: 翻译需求
assignees: ''
---
**需求文档**
请贴出需要翻译的文档链接(基于 [doc.qt.io](doc.qt.io))。
若有一组文档,请贴出链接列表,或用相对精准的语句描述涵盖的文档范围,如多线程并发部分的类文档。
**需求原因**
请给出为何需要社区优先翻译的原因,包括但不限于:
- 有助于社区发展,即对大部分 Qt 开发者和读者更有需求,更适合优先翻译;
- 教学需要,此处指高校等正式类型教学或培训,不包括公众号卖课等商业用途;
- 个人学习需要;
- 个人开发参考需要;
- 商务需要,包括培训机构、自媒体培训、自媒体文章合作、企业需求等。
本社区会优先考虑社区发展需求,其次为教学需求,然后是个人需求和商务需求。
个人需求建议参与社区翻译,能力不足的话可以与社区成员共同合作翻译。
教育需求建议与社区微信群或负责人邮件进行深入联系,社区会协助教师的教学需求进行缺失的文档翻译,以及进一步的教学合作。
商务需求请先考虑赞助社区,或者通过参与翻译、丰富工具链、丰富发布渠道等形式反馈社区。
================================================
FILE: Book/book/.nojekyll
================================================
This file makes sure that Github Pages doesn't process mdBook's output.
================================================
FILE: Book/book.toml
================================================
[book]
authors = ["zhangpengfei1"]
language = "en"
multilingual = false
src = "src"
title = "Qt中文文档"
================================================
FILE: Book/src/BookInfo.md
================================================
# Qt中文文档
本网站github链接
[QtDocumentCN](https://github.com/QtDocumentCN/QtDocumentCN)
gitee镜像链接
[gitee-QtDocument](https://gitee.com/cryfeifei/QtDocumentCN)
# 微信小程序
微信小程序

================================================
FILE: Book/src/SUMMARY.md
================================================
# Summary
- [简介](./BookInfo.md)
- [A]()
- [QAbstractAnimation](./Src/A/QAbstractAnimation/QAbstractAnimation.md)
- [QAbstractAudioDeviceInfo](./Src/A/QAbstractAudioDeviceInfo/QAbstractAudioDeviceInfo.md)
- [QAbstractAudioInput](./Src/A/QAbstractAudioInput/QAbstractAudioInput.md)
- [QAbstractAudioOutput](./Src/A/QAbstractAudioOutput/QAbstractAudioOutput.md)
- [QAbstractAxis](./Src/A/QAbstractAxis/QAbstractAxis.md)
- [QAbstractBarSeries](./Src/A/QAbstractBarSeries/QAbstractBarSeries.md)
- [QAbstractItemModel](./Src/A/QAbstractItemModel/QAbstractItemModel.md)
- [QAbstractSocket](./Src/A/QAbstractSocket/QAbstractSocket.md)
- [QAction](./Src/A/QAction/QAction.md)
- [B]()
- [Best_Practice_Guides](./Src/B/Best_Practice_Guides/Best_Practice_Guides.md)
- [C]()
- [Container_Classes](./Src/C/Container_Classes/Container_Classes.md)
- [QCheckBox](./Src/C/QCheckBox/QCheckBox.md)
- [QComboBox](./Src/C/QComboBox/QComboBox.md)
- [QCoreApplication](./Src/C/QCoreApplication/QCoreApplication.md)
- [D]()
- [QDate](./Src/D/QDate/QDate.md)
- [F]()
- [QFile](./Src/F/QFile/QFile.md)
- [QFileInfo](./Src/F/QFileInfo/QFileInfo.md)
- [G]()
- [QGenericArgument](./Src/G/QGenericArgument/QGenericArgument.md)
- [QGenericReturnArgument](./Src/G/QGenericReturnArgument/QGenericReturnArgument.md)
- [QtGlobal](./Src/G/QtGlobal/QtGlobal.md)
- [I]()
- [QIODevice](./Src/I/QIODevice/QIODevice.md)
- [J]()
- [QJsonArray](./Src/J/QJsonArray/QJsonArray.md)
- [QJsonDocument](./Src/J/QJsonDocument/QJsonDocument.md)
- [QJsonObject](./Src/J/QJsonObject/QJsonObject.md)
- [QJsonParseError](./Src/J/QJsonParseError/QJsonParseError.md)
- [QJsonValue](./Src/J/QJsonValue/QJsonValue.md)
- [L]()
- [QLabel](./Src/L/QLabel/QLabel.md)
- [QLibrary](./Src/L/QLibrary/QLibrary.md)
- [QList](./Src/L/QList/QList.md)
- [M]()
- [Model_View_Programming](./Src/M/Model_View_Programming/Model_View_Programming.md)
- [Model_View_Tutorial](./Src/M/Model_View_Tutorial/Model_View_Tutorial.md)
- [Multithreading_Technologies_in_Qt](./Src/M/Multithreading_Technologies_in_Qt/Multithreading_Technologies_in_Qt.md)
- [QMainWindow](./Src/M/QMainWindow/QMainWindow.md)
- [QMetaClassInfo](./Src/M/QMetaClassInfo/QMetaClassInfo.md)
- [QMetaMethod](./Src/M/QMetaMethod/QMetaMethod.md)
- [QMetaObject](./Src/M/QMetaObject/QMetaObject.md)
- [QMetaProperty](./Src/M/QMetaProperty/QMetaProperty.md)
- [QMetaType](./Src/M/QMetaType/QMetaType.md)
- [QMutex](./Src/M/QMutex/QMutex.md)
- [QMutexLocker](./Src/M/QMutexLocker/QMutexLocker.md)
- [The_Meta-Object_System](./Src/M/The_Meta-Object_System/The_Meta-Object_System.md)
- [Using_the_Meta-Object_Compiler_moc](./Src/M/Using_the_Meta-Object_Compiler_moc/Using_the_Meta-Object_Compiler_moc.md)
- [Why_Does_Qt_Use_Moc_for_Signals_and_Slots](./Src/M/Why_Does_Qt_Use_Moc_for_Signals_and_Slots/Why_Does_Qt_Use_Moc_for_Signals_and_Slots.md)
- [O]()
- [QObject](./Src/O/QObject/QObject.md)
- [P]()
- [QPaintDevice](./Src/P/QPaintDevice/QPaintDevice.md)
- [QPaintEngine](./Src/P/QPaintEngine/QPaintEngine.md)
- [QPainter](./Src/P/QPainter/QPainter.md)
- [QPluginLoader](./Src/P/QPluginLoader/QPluginLoader.md)
- [QtPlugin](./Src/P/QtPlugin/QtPlugin.md)
- [The_Property_System](./Src/P/The_Property_System/The_Property_System.md)
- [Q]()
- [Qt_Namespace](./Src/Q/Qt_Namespace/Qt_Namespace.md)
- [Qt_Overviews](./Src/Q/Qt_Overviews/Qt_Overviews.md)
- [R]()
- [QReadLocker](./Src/R/QReadLocker/QReadLocker.md)
- [QReadWriteLock](./Src/R/QReadWriteLock/QReadWriteLock.md)
- [QRecursiveMutex](./Src/R/QRecursiveMutex/QRecursiveMutex.md)
- [Reentrancy_and_Thread-Safety](./Src/R/Reentrancy_and_Thread-Safety/Reentrancy_and_Thread-Safety.md)
- [Resource_Compiler_rcc](./Src/R/Resource_Compiler_rcc/Resource_Compiler_rcc.md)
- [The_Qt_Resource_System](./Src/R/The_Qt_Resource_System/The_Qt_Resource_System.md)
- [S]()
- [QSctpServer](./Src/S/QSctpServer/QSctpServer.md)
- [QSctpSocket](./Src/S/QSctpSocket/QSctpSocket.md)
- [QSemaphore](./Src/S/QSemaphore/QSemaphore.md)
- [QSql](./Src/S/QSql/QSql.md)
- [QSqlDatabase](./Src/S/QSqlDatabase/QSqlDatabase.md)
- [QSsl](./Src/S/QSsl/QSsl.md)
- [QSslCertificate](./Src/S/QSslCertificate/QSslCertificate.md)
- [QSslCertificate_Obsolete](./Src/S/QSslCertificate_Obsolete/QSslCertificate_Obsolete.md)
- [QSslCertificateExtension](./Src/S/QSslCertificateExtension/QSslCertificateExtension.md)
- [QSslCipher](./Src/S/QSslCipher/QSslCipher.md)
- [QSslConfiguration](./Src/S/QSslConfiguration/QSslConfiguration.md)
- [QSslError](./Src/S/QSslError/QSslError.md)
- [QSslKey](./Src/S/QSslKey/QSslKey.md)
- [QSslSocket](./Src/S/QSslSocket/QSslSocket.md)
- [QSslSocket_Obsolete](./Src/S/QSslSocket_Obsolete/QSslSocket_Obsolete.md)
- [QStyledItemDelegate](./Src/S/QStyledItemDelegate/QStyledItemDelegate.md)
- [Signals_and_Slots](./Src/S/Signals_and_Slots/Signals_and_Slots.md)
- [Synchronizing_Threads](./Src/S/Synchronizing_Threads/Synchronizing_Threads.md)
- [T]()
- [QTcpServer](./Src/T/QTcpServer/QTcpServer.md)
- [QTcpSocket](./Src/T/QTcpSocket/QTcpSocket.md)
- [QTimer](./Src/T/QTimer/QTimer.md)
- [QTransform](./Src/T/QTransform/QTransform.md)
- [U]()
- [QUdpSocket](./Src/U/QUdpSocket/QUdpSocket.md)
- [V]()
- [QVariant](./Src/V/QVariant/QVariant.md)
- [W]()
- [QWebEngineHistory](./Src/W/QWebEngineHistory/QWebEngineHistory.md)
- [QWebEngineHistoryItem](./Src/W/QWebEngineHistoryItem/QWebEngineHistoryItem.md)
- [QWebEngineView](./Src/W/QWebEngineView/QWebEngineView.md)
- [QWriteLocker](./Src/W/QWriteLocker/QWriteLocker.md)
- [X]()
- [QX11Info](./Src/X/QX11Info/QX11Info.md)
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# 参与者公约
## 我们的承诺
为建设开放友好的环境,我们贡献者和维护者承诺:不论年龄、体型、身体健全与否、民族、性征、性别认同与表征、经验水平、教育程度、社会地位、国籍、相貌、种族、信仰、性取向,我们项目和社区的参与者皆免于骚扰。
## 我们的准则
有助于创造积极环境的行为包括但不限于:
* 措辞友好且包容
* 尊重不同的观点和经验
* 耐心接受有益批评
* 关注对社区最有利的事情
* 与社区其他成员友善相处
参与者不应采取的行为包括但不限于:
* 发布与性有关的言论或图像、不受欢迎地献殷勤
* 捣乱/煽动/造谣行为、侮辱/贬损的评论、人身及政治攻击
* 公开或私下骚扰
* 未经明确授权便发布他人的资料,如住址、电子邮箱等
* 其他有理由认定为违反职业操守的不当行为
## 我们的义务
项目维护者有义务诠释何谓“妥当行为”,并妥善公正地纠正已发生的不当行为。
项目维护者有权利和义务去删除、编辑、拒绝违背本行为标准的评论(comments)、提交(commits)、代码、wiki 编辑、问题(issues)等贡献;项目维护者可暂时或永久地封禁任何他们认为行为不当、威胁、冒犯、有害的参与者。
## 适用范围
本行为标准适用于本项目。当有人代表本项目或本社区时,本标准亦适用于此人所处的公共平台。
代表本项目或本社区的情形包括但不限于:使用项目的官方电子邮件、通过官方媒体账号发布消息、作为指定代表参与在线或线下活动等。
代表本项目的行为可由项目维护者进一步定义及解释。
## 贯彻落实
可以致信[zhangpf0313@gmail.com](mailto:zhangpf0313@gmail.com),向项目团队举报滥用、骚扰及不当行为。
维护团队将审议并调查全部投诉,妥善地予以必要的回应。项目团队有义务保密举报者信息。具体执行方针或将另行发布。
未切实遵守或执行本行为标准的项目维护人员,经项目负责人或其他成员决议,可能被暂时或永久地剥夺参与本项目的资格。
## 来源
本行为标准改编自[参与者公约][主页],版本 1.4
可在此查阅:https://www.contributor-covenant.org/zh-cn/version/1/4/code-of-conduct.html
[主页]: https://www.contributor-covenant.org
================================================
FILE: CONTRIBUTING.md
================================================
# 贡献指南
## 提交说明
各种提交代码之前一定要
```shell
git pull --rebase
```
## 目录/文件管理
为方便快速填充内容,以及便于跨文档引用,文档按首字母排序,从A-Z共12个根文件夹。
每一个类新建一个文件夹,将该类的`.md`文件和其它引用的资源文件(如图片)放入其中。
### 范例
比如我想翻译`QX11Info`类。
我要在 X 文件夹下,新建一个 QX11Info 的文件夹。
然后把对应的`QX11Info.md`文档放进去。
----
### 占位符
为避免编辑冲突,在完成第一版翻译前,请尽量不要多人修改同一个页面。
正在为某页面编写第一版翻译的参与者,可提交一个空文档作为占位符,并且在其中注明编写者和 deadline,如:
> Reserved by ZgblKylin until 2020-07-31.
超过 deadline 后尚未完成第一版提交的页面,或已经完成第一版提交的页面,均被视作**开放状态**,其它参与者可对其进行修改。
----
### Obselete Member
对于 `已废弃/Obselete` 的成员,Qt 会在类开头添加一个链接指向单独的页面。
若已废弃的成员数量并不多(独立页面中没有详细信息章节或函数列表),则为减少阅读时的跳转,建议将该页面作为一个单独的章节,附加到原页面尾部。
即将一级标题 `# Obselete Menber` 降级为二级标题 `## 已废弃成员`,其它标题同样进行降级处理。
----
### 子类型
如 [QMetaObject::Connection](Src/M/QMetaObject/QMetaObject_Connection.md) 等子类型,不应单独开文件夹,而是存在隶属类型的文件夹中。
子类型文件名称应带有隶属类型名称,如 `QMetaObject/QMetaObject_Connection.md`。
----
### 所有成员列表
无需单独添加所有成员列表页面。
该页面是类似 `[TOC]` 的目录索引功能,本项目中应交由发布脚本自动生成目录,而非浪费大量人力编写单独的目录页面——单独的页面在检索时需要在不同页面来回跳转,对于读者也不友好。
**注意:** 需对 `List of all members` 页面进行校对,确保其中所有内容均在主文档中有描述。若存在主文档中没有的内容,需将其挪到主文档中。
## 完成度追踪
每添加一个页面,需在[完成度追踪表](completeness_tracking.md)中增加相应条目。
当页面完成编辑、完成维护等状态改变时,维护者有责任在[完成度追踪表](completeness_tracking.md)中更新对应信息。
需要新增或修改一篇文档时,请先检索追踪表中是否已存在该文档,和该文档的翻译进度。
## 参考资料
技术词汇的翻译可参考 [词汇对照表](Comparison_Table.md)。
关于如何将英文文档信达雅地翻译为中文技术文档,可参考 [语法小贴士](Grammar_Tips.md)。
## Markdown 格式规范
可参考模板文件[Template.md](Template.md) ,抑或参考其它的翻译文档。
翻译名词可参考[对照表](Comparison_Table.md)。
### 类成员或实现方法标题
在对类成员或实现方法进行讲解时,我们决定采用 Qt 官方文档的命名方式。
以成员函数标题为例: `[修饰符] 返回类型 函数名(参数类型 参数名) const/volatile/override`。
其中,`函数名 `加粗,`修饰符`、`参数名` 斜体,`const/volatile/override` 等后缀不添加额外修饰。
示例:
```
### *[static]* int QString::**compare**(const QString &*s1*, const QString &*s2*, Qt::CaseSensitivity *cs* = Qt::CaseSensitive)
### *[virtual protected]* void QObject::**childEvent**(QChildEvent \**event*)
### *[override virtual]* qint64 QAbstractSocket::**bytesAvailable**() const
```
> *[static]* int QString::**compare**(const QString &*s1*, const QString &*s2*, Qt::CaseSensitivity *cs* = Qt::CaseSensitive)
>
> *[virtual protected]* void QObject::**childEvent**(QChildEvent *\*event*)
>
> *[override virtual]* qint64 QAbstractSocket::**bytesAvailable**() const
注:对于指针变量`**event*`,请添加转义符 `\`,以避免开头的两个星在多个指针变量中,被渲染为加粗。
----
### 注解
当翻译者需要添加额外的资料或吐槽时,需有明确的标注与官方文档区分开。
若为独立段落,建议使用`>`引用语法,并在开头单独一行标识`译者注:`。
若为段内信息,建议使用段内代码(`译者注:xxx`)的方式标注。
----
### 目录
无需使用`[TOC]`生成目录,因为:
1. `[TOC]`为扩展语法,并非 Markdown 原生语法,GitHub 不支持此扩展。
2. 本项目将使用 GitBook 发布,可自动生成侧边栏目录。
----
### 中英混排
中英混排时,英文内容前后需增加空格分隔,以避免文字过于紧凑:
> 正确写法:
>
> 我要在 X 文件夹下,新建一个 QX11Info 的文件夹。
>
> 错误写法:
>
> 我要在X文件夹下,新建一个QX11Info的文件夹。
文本字段落中的编程关键字,需用段内代码格式包裹,如:
```text
比如我想翻译 `QX11Info` 类。
```
比如我想翻译 `QX11Info` 类。
----
### 图片
可直接使用 Qt 官方文档图片。
但官方文档图片为 png/jpg 格式,分辨率有限,且对主题样式无法自适应,因此推荐使用 [draw.io](https://app.diagrams.net/) 绘制的矢量图形,并将其保存为`.drawio.svg`格式,以便支持`.md`引用的同时,依然可以作为工程文件供 [draw.io](https://app.diagrams.net/) 编辑。
可使用 VSCode 插件 [hediet.vscode-drawio](https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio) 直接在 VSCode 中编辑图形。
范例参见 [信号与槽](S/Signals_and_Slots/Signals_and_Slots.md)。
----
### <del>引用链接</del>
可先留空,后期项目组使用脚本统一处理。
## Markdown 编辑器
### Typora
为规范格式(空行、缩进等),减少多人合作编辑同一`.md`文件时的无意义的 diff 内容,推荐使用 [Typora](https://typora.io/) 编辑器。
该编辑器为类 Word 的所见即所得编辑方式,会自动按照固定格式对 Markdown 源码进行排版,从而避免手动排版与他人排版风格不匹配的问题。
----
### VSCode
若不想下载独立编辑工具,但想直观阅览 Markdown 渲染效果,则可直接使用 VSCode 编辑`.md`文件。
点击 VSCode 的`.md`文件标签页右上角的“打开侧边预览”(Ctrl+K V),或在命令面板(F1)中搜索“Markdown”并选择打开预览(Markdown: Open Preview)即可。
================================================
FILE: Comparison_Table.md
================================================
# 词汇对照表
这里是文档翻译的词汇对照表,详情请见[贡献指南](https://github.com/QtDocumentCN/QtDocumentCN/blob/master/CONTRIBUTING.md)。
| 英 | 汉 |
| --------------------------------- | ---------------- |
| Access functions: | 存取函数 |
| Deprecated | 已弃用 |
| Detailed Description | 详细描述 |
| Emit | 发射 |
| Introspect / Introspection | 自省 |
| Invokable | 可动态调用 |
| Invoke | 动态调用 |
| Marshall | 序列化 |
| Member Function Documentation | 成员函数文档 |
| Member Type Documentation | 成员类型文档 |
| Notifier signal | 通知信号 |
| Obsolete | 废弃的 |
| Post | 投送 |
|Static Public Members | 静态公共成员函数 | |
| Protected Functions | 保护成员函数 |
| Public Functions | 公共成员函数 |
| Public Types | 公共成员类型 |
| Public Signals | 公共信号 |
| Public Slots | 公共槽函数 |
| Qt Assistant | 不翻译 |
| Qt Creator | 不翻译 |
| Qt Designer | 不翻译 |
| Qt Linguist | 不翻译 |
| Reentrant | 重入 |
| Reimplemented Protected Functions | 重写保护成员函数 |
| Reimplemented Public Functions | 重写公共成员函数 |
| Related Non-Members | 相关非成员函数 |
| See also | 另请参阅 |
| Send | 发送 |
| Signals | 信号 |
| Slots | 槽 |
| Static Public Member | 静态公共成员 |
| You | 您 |
================================================
FILE: Grammar_Tips.md
================================================
# 语法小贴士
本文件用于总结翻译英文技术文档时,如何尽可能实现信达雅。
## 翻译原则
1. 尽量使用书面语,避免口语化:
1. 但避免用力过猛,令句子明显诘屈聱牙;
2. 尽量避免出现任何人称代词。
2. 避免过于复杂的长句,用逗号拆分为多个字句,来回避句式杂糅;
3. 避免直译英语语序,这会导致严重的“翻译腔”,需要考虑把有从句的复合句式调整为中文语句;
4. 避免直译英文词组,这是一种逆向的“chinglish”,如“你得到了它”;
5. 仔细斟酌任何一个/组介词的使用,尤其是需要配对使用,或者影响上下文转换的;
6. 仔细斟酌修饰 and/or 的定语(形容词/从句)和状语(副词/从句),避免不小心扩大修饰范围;
7. 仔细斟酌状语、定语、补语的翻译,避免词性发生变化;
8. 仔细斟酌时态的转换,避免出现时态错误;
9. 避免连续使用重复的修饰性词汇,如形容词、副词、介词。
整体目标是做到 ELI5,让读者可以一目十行地快速浏览,同时精读段落时可以保持视线连续移动而不会出现卡顿,即:
1. 让语句结构复合中文习惯,避免生僻用语,并针对句子之间、段落之间的上下文关系适当调整内容结构;
2. 对于每个句子,需要保证内容翻译的精确度,不会出现任何时态、作用域、5W1H 的歧义。
> ELI5: Explain Like I'm 5 (years old)
>
> 5W1H: Who Where When What Why How
## 语句结构
### 调整语句顺序
在状语和定语同时出现时,英文的语句和中文的语序经常是相反的。此时需要调整语句,以避免出现翻译腔。
原文:
> The right solution for a given application depends on the purpose of the new thread and the thread's lifetime.
翻译腔:
> - 正确的解决方案,对于给定的程序,依赖于新线程的用途和线程的生命周期。
> - 对于给定程序的正确的解决方案,依赖于新线程的用途和线程的生命周期。
正确翻译:
> 对一个给定的程序,需要根据新线程的用途与线程的生命周期来决定正确的方案。
----
### 拆分长句
调整语句顺序时,若句式过于复杂,也容易写出虽然语序正确,但阅读时格外吃力的句子,即句式杂糅。
此时,应该使用逗号将长句进行拆分为多个子句。
原文:
> - This global thread pool automatically maintains an optimal number of threads based on the number of cores in the CPU.
> - The Qt Concurrent module provides high-level functions that deal with some common parallel computation patterns: map, filter, and reduce.
句式杂糅:
> - 此公共线程池会自动维持基于 CPU 核心数计算的最佳值的线程数。
> - Qt Concurrent 模块提供了数个用于处理一些常见的并行计算模式的高级函数:map、filter 和 reduce。
正确翻译:
> - 此公共线程池会自动维持一定数量的线程,线程数为基于 CPU 核心数计算的最佳值。
> - Qt Concurrent 模块提供了数个高级函数,用于处理一些常见的并行计算模式:map、filter 和 reduce。
## 标点与词汇
### 标点与空格
- 中英混排时,英文单次前后应该带空格;
- 纯英文句子时,分隔符(逗号句号分号)遵循英文语法,符号前不空格,符号后空格;
- 中英语句通过分隔符连接时,使用中文分隔符,无需空格;
- 引号括号根据内容而定,中英混排时一律使用中文标点;
- **加粗**、`代码` 可考虑前后添加空格增加区分度,但与中文分隔符相连时,同理省略空格;
- 分号是用于分隔长句中互相无关的字句,优先级低于句号——因此在使了句号的列表条目末尾,不应使用分号。
----
### 的、地、得
> 的定 地状 得后补
- **的** 用作 **定语**,即形容词与名词间的连接词(常见的并行计算模式);
- **地** 用作 **状语**,即副词与动词之间的连接词(频繁地创建与销毁线程);
- **得** 用作 **补语**,即动词或形容词后的补充内容(这段代码执行得很频繁)。
----
### 人称代词
- 第一人称:不应出现。在本项目中仅当原文中便以 Qt 维护者的身份叙述问题时出现,即 **我们**。
- 第二人称:避免出现。利用中文可以一定程度省略主语的特性,可以规避绝大多数第二人称的使用。不得不用时,使用 **您**。
- 第三人称:正常使用 **它**。无性别的第三人称代词,在技术文档中常被用于指代抽象概念和对象。
省略主语,同时删除无法配对使用的的连词:
> 如果您频繁地创建或销毁线程,那么资源开销将会非常大。
>
> 如果<del>您</del>频繁地创建或销毁线程,<del>那么</del>资源开销将会非常大。
----
### 反向 Chinglish
避免平铺直叙的直译英文惯用词组,否则会产生很别扭的自造词/句,和 Chinglish 非常类似。
原文:
> Each Qt application has a global thread pool, which is **accessible through** QThreadPool::globalInstance().
错误翻译:
> 每一个 Qt 程序都会自带一个公共线程池,可以通过调用 QThreadPool::globalInstance() 来**获得它**。
正确翻译:
> 每一个 Qt 程序都会自带一个公共线程池,可以通过调用 QThreadPool::globalInstance() 来**获取**。
----
### 介词
介词用于连接语句的不同部分,是形成语句结构的核心部件。介词对组织起语句的 *从属关系、上下文变化、内容转折* 等起着至关重要的作用。
使用介词时,英文和中文的介词都需要仔细斟酌,否则极易出现错误理解,或者表意不明导致歧义。
原文:
> When the script finishes running
错误翻译:
> > 当脚本运行结束后
>
> 当……时
正确翻译:
> > 在脚本运行结束后
>
> 在……后
## 语句成员角色
### 修饰词的作用域
定语、状语、补语都是用于修饰语句中的其它内容。当语句中出现多个被修饰对象,尤其是在同一个语句位置时,需要仔细区分修饰语的限定范围,避免意外扩大、缩小修饰范围,或导致二义性。
原文:
> - QThread can either *be instantiated* **directly or subclassed.** (后两者为 *be instantiated* 的副词)
> - When the script finishes running, it can send a reply back to the GUI thread **which** will invoke the WorkerScript.onMessage() signal handler.(*which* 用于修饰 *GUI thread*)
错误翻译:
> - 您可以*直接* **实例化或子类化** QThread。(作用域改变,*directly* 和 *be instantiated* 被调换了)
> - 在脚本运行结束后,WorkerScript 将会向 GUI 线程发送回复,会调用 WorkerScript.onMessage() 信号处理函数。(从句的作用对象不明,无法确定是 *WorkerScript* 还是 *GUI 线程*)
正确翻译:
> - 您可以**直接** *实例化* QThread,或*建立* **子类**。(保持正确的作用域,*be instantiated* 拆分到两个字句后,用两个词语分别描述)
> - 在脚本运行结束后,WorkerScript 将会向 GUI 线程发送回复,**后者**会调用 WorkerScript.onMessage() 信号处理函数。(通过 *后者* 指明从句的作用对象)
----
### 词性变化
定语、状语、补语都是用于修饰其它语句对象,并且放置的前后位置也非常灵活。
不同词性的内容翻译至中文时,通常会通过附加文字来表示词性,很容易出现词性变化,导致理解错误。
原文:
> > To run code in one of a QThreadPool's threads, reimplement QRunnable::run() and instantiate the **subclassed** QRunnable.
>
> 形容词,与 QRunnable 共同形成宾语
错误翻译:
> > 为了将代码放入 QThreadPool 的线程中运行,可以重写 QRunnable::run() 函数并实例化**继承了** QRunnable 的子类。
>
> **继承了 QRunnable** 第一眼看起来是动宾结构的句式,但往后看到 **的子类** 时,又转换为修饰 **子类** 的定语。因此虽然最终含义与原文一致,但在阅读过程中发生了词性变化,同时导致出现理解错误回滚再重新解读,会严重破坏阅读的流畅性。
正确翻译:
> > 为了将代码放入 QThreadPool 的线程中运行,可以重写 QRunnable::run() 函数并实例化**继承自** QRunnable 的子类。
>
> 词性转换为副词,修饰形容词 **QRunnable 的**,但避免了阅读过程中的错误理解
----
### 时态变化
时态在英文中,通过单词结构的直接变换来表达,偶尔会辅以介词(如 `be processed`)。
但在中文中,时态和词性一样,是通过附加文字来描述的,此时很容易粗心大意导致时态发生变化,影响理解内容。
原文:
> > The Qt Concurrent module **provides** high-level functions that deal with some common parallel computation patterns: map, filter, and reduce.
>
> 一般现在时
时态错误:
> > 公共线程池会自动维持**着**一定数量的线程,线程数为基于 CPU 核心数计算的最佳值。
>
> **着**通常用于表示进行时,并且通常还需伴随另一个子句来共同描述一个完整的动作:
>
> - 小明打着电话,说道……(需要配合子句)
> - 小明正在打电话(现在进行时,可独立成句)
正确翻译:
> > 此公共线程池**会自动维持**一定数量的线程,线程数为基于 CPU 核心数计算的最佳值。
>
> 一般现在时
================================================
FILE: LICENSE
================================================
署名—非商业性使用—相同方式共享 4.0 协议国际版
========================================================================
知识共享组织(“Creative Commons”,“知识共享”) 不是一家律师事务所,也不对
外提供法律服务或建议。提供知识共享公共许可协议(Creative Commons Public
License,以下缩写为CCPL)并不导致“律师—当事人”关系或其他法律关系的建立。
知识共享(Creative Commons)按其现状提供协议文本和相关信息。知识共享
(Creative Commons)对于其许可协议,或通过该协议提供的作品(material)或相关
信息不提供任何担保,在最大可能程度内,也不对因使用其协议或通过该协议提供
的作品(material)或信息而造成的损失承担损害赔偿责任。
知识共享公共许可协议(CCPL)的使用
知识共享公共许可协议(CCPL)提供一套标准化的条款供作者或其他权利人使用,
以便他们分享其原创作品(original works of authorship)和其他受著作权和以下
公共许可协议中提及的其他特定权利保护的作品(material)。以下考虑因素仅供参
考,并未列举穷尽,也不属于本公共许可协议文本的一部分。
许可人应当考虑的因素:知识共享(Creative Commons)公共许可协议是供那
些有权许可公众以著作权或其他特定权利所保护的方式使用其作品
(material)的权利人使用的。知识共享(Creative Commons)协议不可撤销。
因此,在采用协议前,许可人应当阅读并理解其所选择的协议条款。许可人
亦应确保其享有所授予公众的权利,以便公众能够顺利的使用授权作品
(material)。许可人应当清楚地注明协议所不适用的作品(material),包括
其他采用知识共享协议授权的作品(material),或基于著作权的例外或限制
而使用的作品(material)。许可人应该考虑的其他因素:
wiki.creativecommons.org/Considerations_for_licensors
公众应当考虑的因素: 许可人通过使用知识共享(Creative Commons)协议,
授权公众依据特定的条款和条件使用授权作品(Licensed Material)。如果因
为任何原因不需要授权即可使用该作品(material)——例如基于著作权的例
外或限制——那么该使用并不受本协议约束。许可人通过知识共享(Creative
Commons)协议只能授予基于著作权或其他特定权利有权授予的许可。使用授
权作品(Licensed Material)可能还受到其他情形的限制,包括第三方对该作
品(material)所享有的著作权或其他权利。许可人可能做出其他特别要求,
比如要求使用者标注或说明对作品(material)的所有更改。即使本协议没有
要求,知识共享(Creative Commons)仍然鼓励您遵守许可人的合理要求。
公众应当考虑的其他因素:
wiki.creativecommons.org/Considerations_for_licensees
========================================================================
知识共享 (Creative Commons) 署名—非商业性使用—相同方式共享 4.0公共许可协议国际版
通过行使本协议所授予的权利(定义如下),您接受并同意受到知识共享
(Creative Commons)署名—非商业性使用—禁止演义4.0国际公共许可协议(以下
简称“本公共许可协议”)的约束。从合同解释的角度来看,您获得授权的对价是接
受本协议的条款,许可人授予您这些权利的对价是可以通过采用本协议条款发布授
权作品(material)而获得利益。
第一条 定义
a. 演绎作品(Adapted Material): 指受到著作权与类似权利保护的,基于授权
作品(Licensed Material)而创作的作品(material),例如对授权作品
(Licensed Material)的翻译、改编、编排、改写或其他依据著作权与类似权
利需要获得所有人许可的修改。为本公共许可协议之目的,当授权作品
(Licensed Material)为音乐作品、表演或录音时,将其依时间序列关系与动
态影像配合一致而形成的作品,视为演绎作品(Adapted Material)。
b. 演绎作者的许可: 指您依据本公共许可协议对在演绎作品(Adapted
Material)中自己所贡献的部分所享有的著作权与类似权利进行授权的协议。
c. 署名—非商业性使用—相同方式共享兼容协议: 指在
creativecommons.org/compatiblelicenses 上列出且经知识共享组织
(Creative Commons)认可、实质上与本公共许可协议相当的协议。
d. 著作权与类似权利: 指著作权和/或与著作权紧密联系的类似权利。类似权
利包括但不限于:表演者权、广播组织权、录音录像制作者权、以及数据库
特别权利,而不论上述权利的定义和归类如何。为本公共许可协议之目的,
第二条b款第(1)项与第(2)项 所列权利不属于著作权与类似权利。
e. 有效的技术措施: 指根据各司法管辖区遵循《世界知识产权组织版权条约》
(1996年12月20日通过)第十一条或类似国际协定项下的义务所制定的法
律,在没有适当的授权的情况下,禁止使用者规避的技术措施。
f. 例外与限制: 指合理使用(Fair Dealing and Fair Use)和/或其他适用于您
对授权作品(Licensed Material)的使用的著作权与类似权利的例外或限制。
g. 授权要素: 指知识共享公共许可协议(CCPL)名称中所包含的协议特征。本公
共 许可协议的授权要素包括:署名、非商业性使用和相同方式共享。
h. 授权作品(Licensed Material): 指许可人通过本公共许可协议授权的文
学、艺术作品(artistic or literary work),数据库或其他作品
(material)。
i. 协议所授予的权利: 指依据本公共许可协议的条款和条件所授予您的各项权
利,限于适用于您对授权作品(Licensed Material)的使用且许可人有权许可
的著作权与类似权利。
j. 许可人: 指通过本公共许可协议进行授权的个人或组织。
k. 非商业性使用: 指该使用的主要意图或者指向并非获取商业优势或金钱报
酬。为本公共许可协议之目的,以数字文件共享或类似方式,用授权作品
(Licensed Material)交换其他受到著作权与类似权利保护的作品(material)
是非商业性使用,只要该交换不涉及金钱报酬的支付。
l. 分享: 指以需要“协议所授予的权利”许可的任何方法或程序向公众提供作品
(material),包括复制、公共展示、公开表演、发行、散布、传播、进口或
提供作品(material)给公众以便其能在其选定的时间和地点接收作品
(material)。
m. 数据库特别权利: 指除了著作权之外,衍生于1996年3月11日通过的《欧洲
议会与欧盟理事会关于数据库法律保护的指令》(Directive 96/9/EC)及其修
改或后续版本的权利,或其他国家或地区本质上与之等同的权利。
n. 您: 指依据本公共许可协议行使其所获得授予之权利的个人或机构。 “您
的” 有相应的含义。
第二条 授权范围
a. 授权
1. 根据本公共许可协议的条款,许可人授予您在全球范围内,免费的、不
可再许可、非独占、不可撤销的许可,以对授权作品(Licensed
Material)行使以下“协议所授予的权利”:
a. 复制和分享授权作品(Licensed Material)的全部或部分,仅限于
非商业性使用;以及
b. 为非商业目的创作、复制演绎作品(Adapted Material),但不得
分享该演绎作品。
2. 例外和限制 为避免疑义,若著作权的例外和限制适用于您对授权作品
(Licensed Material)的使用,本公共许可协议将不适用,您也无须遵
守本公共许可协议之条款。
3. 期限 本公共许可协议的期限规定于第六条a款。
4. 媒介和形式;允许的技术修改 许可人授权您在任何媒介以任何形式
(不论目前已知的或未来出现的)行使本协议授予的权利,并为之进行
必要的技术修改。许可人放弃和/或同意不主张任何权利以阻止您为了
行使协议项下权利进行必要的技术修改,包括为规避有效技术措施所必
须的技术修改。为了本公共许可协议之目的,基于本协议第二条a款第
(4)项进行的技术修改不构成演绎作品(Adapted Material)。
5. 后续接受者。
a. 来自许可人的要约——授权作品(Licensed Material) 本授权作
品(Licensed Material)的每一个后续接受者都自动取得许可人的
要约,以按照本公共许可协议的条款行使协议授予的权利。
b. 来自许可人的额外要约——演绎作品(Adapted Material) 您基于授
权作品(Licensed Material)创作的演绎作品(Adapted Material)
的每一个后续接受者都自动取得许可人的要约,以按照您所适用的
“演绎作者的许可”协议的条款行使协议所授予的权利。
c. 禁止下游限制 若会限制授权作品(Licensed Material)后续接受
者行使本协议所授予的权利,则您不得对授权作品(Licensed
Material)提出或增加任何额外的或不同的条款,或使用任何有效
技术措施。
6. 并非背书 本公共许可协议不构成、或不得被解释为允许您声明或主张:
您或您对授权作品(Licensed Material)的使用与许可人(或第三条a款
第(1)项(A)目(i)所规定要求提供署名的权利人)相关联,或得到其赞
助、同意或被授予正式地位。
b. 其他权利
1. 依据本公共许可协议,著作人身权,例如保护作品完整权、形象权、隐
私权或其他类似的人格权利,不在许可范围内。但是,在条件允许的情
况下,许可人可以在必要范围内放弃和/或同意不主张其权利,以便您
行使本协议所授予的权利。
2. 本公共许可协议不适用于任何专利权或商标权许可。
3. 在自愿的或可放弃的法定或强制许可机制下,许可人在最大可能范围内
放弃对您因行使本协议所授予的权利而产生的使用费的权利,不论是直接
收取或通过集体管理组织收取。在其他任何情况下(包括授权作品
(Licensed Material)被商业性使用的情形),许可人明确保留收取使用费
的任何权利。
第三条 授权条件
您行使被许可的权利明确受以下条件限制:
a. 署名
1. 若您分享本授权作品(Licensed Material),您必须:
a. 保留如下标识(如果许可人提供授权作品(Licensed Material)的
同时提供如下标识):
i. 以许可人要求的任何合理方式,标识本授权作品(Licensed
Material)创作者和其他被指定署名的人的身份(包括指定
的笔名);
ii. 著作权声明;
iii. 有关本公共许可协议的声明;
iv. 有关免责的声明;
v. 在合理可行情况下,本授权作品(Licensed Material)的网
址(URI)或超链接;
b. 表明您是否修改本授权作品(Licensed Material)及保留任何先前
修改的标记;及
c. 表明授权作品(Licensed Material)依据本公共许可协议授权,并
提供本公共许可协议全文,或者本公共许可协议的网址(URI)或超
链接。
2. 依据您分享本授权作品(Licensed Material)的媒介、方法及情況,您
可以采用任何合理方式满足第三条a款第(1)项的条件。例如,提供包含
所要求信息来源的网址(URI)或超链接可算是合理地满足此处的条件。
3. 如果许可人要求,您必须在合理可行的范围内移除第三条a款第(1)项
(A)目所要求的任何信息。
b. 相同方式共享
除第三条a款的条件外,如果您分享您创作的演绎作品(Adapted Material),
则下列条件也适用:
1. 您适用的“演绎作者的许可”协议必须是与本许可协议具有相同授权要素
的知识共享(Creative Commons)许可协议(可以是本版本或后续版本),
或者其他与“署名-非商业性使用-相同方式共享”协议兼容的许可协议。
2. 您必须提供您适用的“演绎作者的许可”协议全文或者该许可协议的网址
(URI)或超链接。依据您分享您的演绎作品(Adapted Material)所使用的
媒介、方法及情況,您可以采用任何合理方式满足此条件。
3. 您不得提出或施加任何附加或不同的条款或条件、或在演绎作品(Adapted
Material)上应用任何有效的技术措施,以限制使用者行使依您所适用的
“演绎作者的许可”协议所授予的权利。
第四条 数据库特别权利
当协议所授予的权利包含数据库特别权利,而该数据库特别权利适用于您对授权作
品(Licensed Material)的使用时:
a. 为避免疑义,第二条a款第(1)项授权您,仅限于以非商业性目的,摘录、再
利用、复制和分享全部或绝大部分数据库资料;
b. 如果您将数据库资料的全部或绝大部分纳入您享有数据库特别权利的另一数
据库,则您享有数据库特别权利的该数据库(而非其中的单个内容)视为演
绎作品(Adapted Material),适用第三条b款的要求;
c. 如果您分享全部或大部分该数据库的资料,您必须遵守第三条a款规定的条
件。
为避免疑义,当协议所授予的权利包含其他著作权与类似权利时,第四条补充且不
取代本公共许可协议所规定的您的义务。
第五条 免责声明及责任限制条款
a. 除非许可人另有保证,否则在最大可能范围内,许可人按其现状和现有之基
础提供授权作品(Licensed Material),且没有就授权作品(Licensed
Material)做出任何形式的陈述或保证:无论明示、默示、法定或其他形式,
包括但不限于任何有关本授权作品(Licensed Material)的权属保证、可交易
性、适于特定目的、未侵害他人权利、没有潜在或其他瑕疵、精确性或是否
有错误,不管是否已知或可发现。当免责声明全部或部分不被允许时,此免
责声明可能不适用于您。
b. 在最大可能范围内, 对于任何因本公共许可协议或使用授权作品(Licensed
Material)引起的直接的、特殊的、间接的、附随的、连带的、惩罚性的、警
告性的,或其他的损失、成本、费用或损害,许可人不对您负任何法律上或
其他的责任(包括但不限于过失责任)。当责任限制部分或全部不被允许
时,该限制不适用于您。
c. 前述免责及责任限制声明,应尽可能以最接近于完全排除全部责任的方式解
释。
第六条 期限与终止
a. 本公共许可协议在著作权与类似权利存续期间内有效。然而,如果您没有遵
守此公共许可协议,则您依据此公共许可协议享有的权利自动终止。
b. 当您使用本授权作品(Licensed Material)的权利根据第六条a款终止时,您
的权利在下述情况下恢复:
1. 自违反协议的行为纠正之日起自动恢复,但须在您发现违反情形后30日
内纠正;或
2. 根据许可人明示恢复权利的意思表达。
为避免疑义,本公共许可协议第六条b款不影响许可人就您违反本公共许可协
议的行为寻求法律救济。
c. 为避免疑义,许可人也可在任何时间,以另外的条款或条件提供本授权作品
(Licensed Material),或者停止传播本授权作品(Licensed Material);然
而,许可人此种行为不会终止本公共许可协议。
d. 本协议第一、五、六、七及第八条,不因本公共许可协议终止而失效。
第七条 其他条款和条件
a. 除非明示同意,否则许可人不受您表达的任何附加或不同条款或条件约束。
b. 本公共许可协议未提及的关于授权作品(Licensed Material)之任何安排、共
识或协议,不属于且独立于本公共许可协议的条款及条件。
第八条 解释
a. 为避免疑义,本许可协议不会也不应被解释为减少、限制、约束或施加条件
于无需本公共许可协议授权即可依法行使的对授权作品(Licensed Material)
的任何使用。
b. 在最大可能范围内,如果本公共许可协议的任何条款被视为无法执行,该条
款在必要的最小限度内,自动调整至可以执行。如果该条款不能被调整,其
应自本公共许可协议中排除适用,不影响其余条款的效力。
c. 除许可人明示同意,本公共许可协议的任何条款或条件均不得放弃。
d. 本公共许可协议条款不构成、也不得被解释为限制或者放弃适用于许可人或
您的特权或豁免,包括豁免于任何司法管辖区或行政机构的法律程序。
=======================================================================
知识共享组织(Creative Commons)不是其公共许可协议的一方 。尽管如此,知识
共享组织(Creative Commons)可以选择其中一种公共许可协议适用于其发表的作品
(material),在此种情况下被视为许可人。知识共享公共许可协议(CCPL)的文本属
于公共领域,适用CC0公共许可协议。 除用于向公众表明本作品(material)是依照
知识共享(Creative Commons)公共许可协议授权,或发布于
creativecommons.org/policies 的知识共享(Creative Commons)政策另有规定允许
以外,如未经知识共享组织(Creative Commons)事先书面同意,任何一方均不得使
用“知识共享”(Creative Commons)商标和其他相关商标及标识。包括但不限于,将
该商标或标识用于对知识共享公共许可协议(CCPL)做出的未经同意的修改,或与授
权作品(Licensed Material)使用有关的其他安排、共识或协议。为避免疑义,本
段关于商标的限制性规定不构成公共许可协议之一部分。
您可以通过 creativecommons.org 联系知识共享组织(Creative Commons)。
================================================
FILE: Logo/README.md
================================================
# Logo 设计
方形图标:




圆形图标:

## 设计思路
基于 [Qt 官方图标](www.qt.io),添加 `中文文档` 字样。
图标全程使用 `svg` 资源,以便在所有分辨率下都得到较好的显示效果。
使用 [Draw.io](www.draw.io) 编辑生成最终图像。
### 方形图标
参考 chm 和 Qt4 Aassistant 的图标风格,在右下角添加问号标识。
填充文字时,带问号版缩放高度至 `16pt`,无问号版缩放高度至 `20pt`。绿色字体因为边缘不明显,带问号版略微放大高度至 `17pt`。
### 圆形图标
设置 70x70pt 的圆,在适当位置放置 `Qt` 官方图标和 `中文文档` 字样,官方图标大小不变,文本缩放高度至 `19pt`。
添加 70x70pt 的外接矩形,采用相同尺寸。
## 资源来源
### Qt图标
原始图标来自 [Qt 官方网站](www.qt.io) 内嵌 `svg` 代码。

----
### 问号字样
<img src="Question.svg" width="81" height="108.6">
问号图像使用 [FontAwesome](http://www.fontawesome.com.cn/) 字体中的 [Question 符号](http://www.fontawesome.com.cn/icons/question/),并修改颜色为 Qt 配色,添加白色描边:
```html
<path ... fill="#41cd52" stroke-width="30" stroke="white"/>
```
----
### 中文文档字样


使用 [Noto Sans CJK SC Bold](https://www.google.com/get/noto/help/cjk/) 字体,即 [思源黑体](https://github.com/adobe-fonts/source-han-sans) 的粗体效果。
基于 [text-to-svg](https://github.com/shrhdk/text-to-svg) 模块,使用 `Node.js` 将文本的字形转换为 `svg` 图像:
```javascript
// 导入 text-to-svg 模块
const TextToSVG = require('text-to-svg');
// 加载字体,创建对象
const textToSVG = TextToSVG.loadSync('字体路径/NotoSansCJKsc-Bold.otf');
// 主题色填充,无描边
const attributes = {fill: '#41cd52'};
// 使用 72 磅渲染
const options = {x: 0, y: 0, fontSize: 72, anchor: 'top', attributes: attributes};
// 渲染文本,生成 svg
var fs = require("fs");
fs.writeFile("Text_green.svg", textToSVG.getSVG('中文文档', options), () => {});
```
================================================
FILE: README.md
================================================
由于ChatGPT项目的火爆,这个项目目前没有必要继续了。
感谢大家的热情参与
微信留着,欢迎各位添加好友~
Made with [contributors-img](https://contributors-img.web.app).
================================================
FILE: Src/A/API_Design_Principles/API_Design_Principles.md
================================================
# API 设计规范
> 译者注:
>
> 本文不来自于 Qt 文档,而是来自于 Qt Wiki:[API_Design_Principles](https://wiki.qt.io/API_Design_Principles)
>
> API(Application Programming Interface),应用开发接口,本文中也将 P 解释为 Programmer(开发者)。
Qt 最出名的特点之一是一致性强、易于学习、功能强大的 API。本文尝试对我们在设计 Qt 风格的 API 中积累的诀窍进行总结。其中许多准则都是通用的,其它的则是习惯性用法,我们主要为了保持接口一致性而继续遵循。
尽管这些准则主要面向公共接口,但也鼓励您在设计内部接口时使用相同的技术,这对与您合作开发的同僚会更加友好。
您可能也会有兴趣查阅 Jasmin Blanchette 的 [Little Manual of API Design (PDF)](https://people.mpi-inf.mpg.de/~jblanche/api-design.pdf),或它的前身,由 Matthias Ettrich 编写的 [*Designing Qt-Style C++ APIs*](https://doc.qt.io/archives/qq/qq13-apis.html)。
## 优秀接口的六大特点
API 是面向开发者的,而 GUI 则是面向终端用户。API 中的 P 代表开发者(Programmer),而非程序(Program),目的是指出 API 由开发者,即人类(而非计算机)所使用这一特点。
Matthias 在 Qt 季刊弟13期,关于 API 设计的文章中,声称他坚信 API 应该是最小化但完备的,具备清晰而简洁的语义,符合直觉,被开发者,易于记忆,能够引导开发者编写高可读性的代码。
----
#### 最小化
最小化的 API 指包含尽可能少的公共成员和最少的类。这可让 API 更易于理解、记忆、调试和修改。
----
#### 完备性
完备的 API 意味着具备所有应有的功能。这可能会与最小化产生冲突。此外,若一个成员函数位于错误的类中,则大多数潜在的用户回无法找到它。
----
#### 清晰简洁的语义
与其它设计协作时,应该让您的设计做到最小例外。通用化会让事情更简单。特例可能存在,但不应成为关注的焦点。在处理特定问题时,不应让解决方案过度泛化。(例如,Qt 3 中的 `QMineSourceFactory` 本该被称作 `QImageLoader`,并且具备另一套 API。)
----
#### 复合直觉
如同计算机上其它内容,API 应复合直觉。不同的开发经验和技术背景会导致对复合直觉与否有不同的感知。复合直觉的 API 应能让中等经验的开发者无需阅读文档并直接使用,并让不知道这个 API 的开发者可以理解使用它编写的代码。
----
#### 易于记忆
为了让 API 易于记忆,请选择一组保持一致并足够精确的命名约定。使用可理解的模式和概念,并且避免缩写。
----
#### 可读性导向
编写代码只需要一次,但阅读(以及调试和修改)则会非常频繁。高可读性的代码通常需要花更多时间编写,但可以在产品的生命周期中节约更多的时间。
最后需要谨记,不同类型的用户会使用 API 的不同部分。在单纯地创建一个 Qt 类实例能非常直观的同时,希望用户在尝试继承它之前先阅读文档则是很合理的。
## 静态多态
相似的代码类应具有相似的 API。可以使用继承来实现——当运行时多态支持时,这是很合理的。但多态同时也可以体现在设计截断。例如,若将代码中的 `QProgressBar` 换为 `QSlider`,或将 `QString` 换为 `QByteArray`,他们间相似的 API 会另替换操作变得非常容易。这便是为何我们称之为“静态多态”。
静态多态同样可让记忆 API 和开发模式变得更加简单。结果是,对于一组有关联的类,相似的 API 通常比为每个类独立设计的完美 API 更加好用。
在 Qt 中,当不具备有足够说服力的原因时,我们更倾向于使用静态多态,而非继承。这减少了 Qt 的公共类数量,并让新用户更容易在文档中找到需要的内容。
----
### 好的
`QDialogBox` 和 `QMessageBox` 具有相似的 APi,以用于处理按钮(`addButton()`, `setStandardButtons()`,但无需继承自某些 "QAbstractButtonBox" 类。
----
### 坏的
`QAbstractSocket` 被 `QTcpSOcket` 和 `QUdpSocket` 所继承,但这两个类的交互方式差异很大。看起来并没有人使用过(或能够使用) `QAbstractSocket` 指针来进行通用且有效的操作。
----
### 存疑
`QBoxLayout` 是 `QHBoxLayout` 和 `QVBoxLayout` 的基类。优点:可以在工具栏中使用 `QBoxLayout`,调用 `setOrientation()` 来令其水平/垂直排布。缺点:引入额外的类,用户可能会写出形如 `((QBoxLayout *)hbox)->setOrientation(Qt::Vertical)` 的代码,而这是不合理的。
## 基于属性的 API
比较新的 Qt 类倾向于使用基于属性的 API,例如:
```c++
QTimer timer;
timer.setInterval(1000);
timer.setSingleShot(true);
timer.start();
```
此处的*属性*,指的是作为对象状态一部分的任何概念性的特征——无论是否是实际的 `Q_PROPERTY`。只要可行,用户都应该允许以任何顺序设置属性,也就是说,这些属性应该是正交的。例如,上文的代码也可以写为:
```c++
QTimer timer;
timer.setSingleShot(true);
timer.setInterval(1000);
timer.start();
```
为了方便,我们也可以这样写:
```c++
timer.start(1000);
```
类似的,对于 `QRegExp`,我们可以:
```c++
QRegExp regExp;
regExp.setCaseSensitive(Qt::CaseInsensitive);
regExp.setPattern(".");
regExp.setPatternSyntax(Qt::WildcardSyntax);
```
为了实现此类 API,内部的对象需要被惰性构造。例如在 `QRegExp` 的案例中,不应该在还不知道表达式使用何种语法之前,就在 `setPattern()` 中过早地编译 `.` 表达式。
属性通常是级联的,此时我们应该谨慎地处理。仔细考虑下当前样式提供的“默认图标大小”与 `QToolButton` 的 `iconSize` 属性:
```c++
toolButton->iconSize(); // 返回当前样式表的默认大小
toolButton->setStyle(otherStyle);
toolButton->iconSize(); // 返回 otherStyle 的默认大小
toolButton->setIconSize(QSize(52, 52));
toolButton->iconSize(); // 返回 (52, 52)
toolButton->setStyle(yetAnotherStyle);
toolButton->iconSize(); // 返回 (52, 52)
```
注意,一旦 `iconSize` 被设置,它会被一直留存,此时修改当前样式不会影响它。这是 **好的**。有时,提供重置属性的渠道会很方便,这有两种实现方式:
- 传递一个特定值(如 `QSIze()`、`-1 `或 `Qt::Alignment(0)`)来指代“重置”;
- 提供显示的 `resetFoo()` 或 `unsetFoo()` 函数。
对于 `iconSize`,将 `QSize()`(即 `QSize(-1, -1)`)设为“重置”便足够了。
某些场景中,取值方法会返回值会与设置的内容不同。例如,若调用 `widget->setEnabled(true)`,可能通过 `widget->isEnabled()` 获得的依然是 `false`,因为父控件被禁用了。这并没问题,因为通常这正是我们要检查的状态(父控件被禁用时,子控件也应该变灰,表现为也被禁用,但同时在它内部,应该知道自己实际是“可用”的,并等待父控件可用后恢复状态),但必须在文档中正确地进行描述。
----
## QProperty
> 译者注:该类型为 Qt 6.0 引入,需要参见 Qt 6 类文档。
>
> 本文原文中的内容与现有的 Qt 6.0 预览版存在出入,因此暂不翻译本节,待官方进一步维护更新原文。
## C++ 特性
### 值 与 对象
> 译者注:此条原文无内容,待官方更新
----
### 指针 与 引用
作为输出参数,指针与引用哪个更好?
```c++
void getHsv(int *h, int *s, int *v) const void getHsv(int &h, int &s, int &v) const
```
绝大多数 C++ 数据都推荐尽可能使用引用,因为引用在感知上比指针“更安全更漂亮”。事实上,我们在 Qt 软件中更倾向于使用指针,因为这会令代码更加已读。如对比:
```c++
color.getHsv(&h, &s, &v);
color.getHsv(h, s, v);
```
第一行代码能很清晰地表示,`h`、`s`、`v` 对象有很大概率会被该函数调用所修改。
即便如此,由于编译器并不喜欢输出参数,在新 APi 中应该避免此用法,而是返回一个小结构体:
```c++
struct Hsv { int hue, saturation, value }; Hsv getHsv() const;
```
> 译者注:对于可能失败的带返回值的函数,Qt 倾向于返回数值,使用 `bool* ok = 0` 参数来存储调用结果,以便在不关心时忽略之。同样在 Qt 6 以后,该方式不再被建议使用,而是改用 `std::optional<T>` 返回类型。
----
### 传递常引用 与 传递值
若类型大于16字节,传递常引用。
若类型具有[非平凡的拷贝构造函数](https://zh.cppreference.com/w/cpp/language/copy_constructor#.E5.B9.B3.E5.87.A1.E5.A4.8D.E5.88.B6.E6.9E.84.E9.80.A0.E5.87.BD.E6.95.B0)或[非平凡的析构函数](https://zh.cppreference.com/w/cpp/language/destructor#.E5.B9.B3.E5.87.A1.E6.9E.90.E6.9E.84.E5.87.BD.E6.95.B0),传递常引用来避免执行这些方法。
所有其它类型都应使用值传递。
范例:
```c++
void setAge(int age);
void setCategory(QChar cat);
void setName(QLatin1String name);
void setAlarm(const QSharedPointer<Alarm> &alarm); // 常引用远快于拷贝构造和析构
// QDate, QTime, QPoint, QPointF, QSize, QSizeF, QRect 都是其它应该值传递的好例子
```
----
### 虚函数
当 C++ 中的一个成员函数被声明为虚函数,这主要用于通过在子类中重写来自定义该函数的行为。将函数设为虚函数的目的是让对该函数的现有调用会被替代为访问自定义的代码分支。若在该类之外没人调用此函数,则在将其声明为虚函数之前需要小心斟酌:
```c++
// Qt 3 中的 QTextEdit: 成员函数不需要作为虚函数的成员函数
virtual void resetFormat();
virtual void setUndoDepth( int d );
virtual void setFormat( QTextFormat &f, int flags );
virtual void ensureCursorVisible();
virtual void placeCursor( const QPoint &pos;, QTextCursorc = 0 );
virtual void moveCursor( CursorAction action, bool select );
virtual void doKeyboardAction( KeyboardAction action );
virtual void removeSelectedText( int selNum = 0 );
virtual void removeSelection( int selNum = 0 );
virtual void setCurrentFont( const QFont &f );
virtual void setOverwriteMode( bool b ) { overWrite = b; }
```
当 `QTextEdit` 从 Qt 3 迁移至 Qt 4 时,几乎所有虚函数都被移除。有趣的是(但并未预料到),并没有大量的抱怨。为什么?因为 Qt 3 并未使用 `QTextEdit` 的多态性,Qt 3 并不会调用这些函数——只有使用者会。简单来说,否则并没有任何理由去继承 `QTextEdit` 并重写这些方法——除非您自己会通过多态去调用它们。若您需要在您的应用程序,也就是 Qt 之外使用多态机制,您应该自行添加。
#### 避免使用虚函数
在 Qt 中,我们因为多种原因而尝试最小化虚函数的数量。每个虚函数调用都会让缺陷修复变得更难,因为会在调用图中插入一个不受控制的节点(使得调用结果无法预测)。人们会在虚函数中做非常疯狂的举措,例如:
- 发送事件
- 发送信号
- 重入事件循环(例如,打开一个模态文件对话框)
- 删除对象(例如,某些导致 `delete this` 的操作)
此外还有一些避免过度使用虚函数的原因:
- 无法在不破坏二进制兼容性的前提下增加、移动或删除虚函数
- 无法简便地重写虚函数
- 编译器通常几乎不会内敛虚函数调用
- 调用虚函数需要查询虚表,导致其比常规函数调用慢2-3倍
- 虚函数另类对象更难进行值拷贝(可能做到,但会表现得很混乱且不被推荐)
过去的经验告诉我们,没有虚函数地类会产生更少的错误,通常也导致更少的维护。
一个通用的经验法则是,除非从工具集或该类的主要使用者角度需要调用它,否则一个函数不应该是虚函数。
#### 虚对象 与 可复制性
多态对象和值类型的类并不是好朋友。
包含虚函数的类会有虚析构函数来避免基类析构时未清理子类数据导致的内存泄漏。
若需要以值语义拷贝、复制和对比一个类,则可能需要拷贝构造函数、赋值运算符重载和等于运算符重载:
```c++
class CopyClass {
public:
CopyClass();
CopyClass(const CopyClass &other);
~CopyClass();
CopyClass &operator=(const CopyClass &other);
bool operator== (const CopyClass &other) const;
bool operator!=(const CopyClass &other) const;
virtual void setValue(int v);
};
```
若创建该类的子类,则代码中会开始发生意料外的行为。通常来说,若没有虚函数和虚构造函数,则人们无法创建依赖于多态特性的子类。因此一旦虚函数或虚析构函数被添加,这会马上成为建立子类的理由,事情从此变得复杂。*乍一看来,很容易觉得可以简单定义一下虚运算符重载*。但顺着这条路深入下去,会导致混乱和毁灭(例如无可读性的代码)。请研究下这段代码:
```c++
class OtherClass {
public:
const CopyClass &instance() const; // 此处会返回什么?我应该将返回值赋值给谁?
};
```
(此小节正在施工中)
----
### 不变性
C++ 提供了 `const` 关键字来标识不会改变或不会产生副作用的事物。它可被用于数值、指针和倍只想的内容,也可被作为成员函数的特殊属性来标识它不会修改对象的状态。
注意,`const` 自身并不提供太大的价值——许多语言甚至并未提供 `const` 关键字,但这并不会自动导致它们存在缺陷。事实上,若移除所有函数重载,并通过搜索替换移除 C++ 代码中的所有 `const` 标识,代码很可能依然能够编译并正确执行。使用实用主义导向来使用 `const` 是很重要的。
让我们看看 Qt 中使用 `const` 的 API 设计:
#### 输入参数:`const` 指针
使用指针输入参数的 `const` 成员函数几乎总是使用 `const` 指针。
若一个成员函数确实被声明为 `const`,这意味着它不具有副作用,也不会修改对象对外可见的状态。那么,为什么要需要非 `const` 的输入参数?需要牢记,`const` 成员函数经常会被其它 `const` 成员函数,在这些调用场合中,非 `const` 的指针并不容易得到(除非使用 `const_cast`,而我们应该尽可能避免使用它)。
修改之前:
```c++
bool QWidget::isVisibleTo(QWidget *ancestor) const;
bool QWidget::isEnabledTo(QWidget *ancestor) const;
QPoint QWidget::mapFrom(QWidget *ancestor, const QPoint &pos) const;
```
`QWidget` 声明了大量使用非 `const` 指针作为输入参数的 `const` 成员函数。注意,虽然这些函数不能修改调用的控件本身,但是可以修改传入的控件。这类成员函数经常会伴随 `const_cast` 所使用。此类成员函数使用 `const` 输入参数会更合适。
修改之后:
```c++
bool QWidget::isVisibleTo(const QWidget *ancestor) const;
bool QWidget::isEnabledTo(const QWidget *ancestor) const;
QPoint QWidget::mapFrom(const QWidget *ancestor, const QPoint &pos) const;
```
注意,我们在 `QGraphicsItem` 中修复了这些成员函数,但 `QWidget` 的修复需要等待 Qt 5:
```c++
bool isVisibleTo(const QGraphicsItem *parent) const;
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const;
```
#### 返回值:`const` 值
函数的返回值,要么是引用类型,要么是[右值](https://zh.cppreference.com/w/cpp/language/value_category#.E5.8F.B3.E5.80.BC)。
非类类型的右值是不受[cv限定符](https://zh.cppreference.com/w/cpp/language/cv)影响的。因此,即使在语法上允许为其添加 `const` 修饰,这并不会产生效果,因为由于其访问权不允许对其做出修改。大多数现代编译器在编译此类代码时会打印警告信息。
当为类类型的右值添加 `const` 时,对该类的非 `const` 的成员函数的访问会被禁止,对其成员变量的直接操作也会被禁止。
不添加 `const` 允许此类操作,但很少有此类需求,因为这些修改会伴随右值对象生命周期的结束而消失,这会在当前语句的分号结束后发生。
例如:
```c++
struct Foo {
void setValue(int v) { value = v; } int value;
};
Foo foo() { return Foo(); }
const Foo cfoo() { return Foo(); }
int main() {
// 下述代码可以编译,foo() 返回非 const 右值,无法
// 成为赋值目标(这通常需要左值),但对成员变量的访问
// 是左值:
foo().value = 1; // 可以编译,但该临时值在这个完整的表达式结束后会被抛弃
// 下述代码可以编译,foo() 返回非 const 右值,无法
// 成为赋值目标,但可以调用(甚至于非 const 的)成员函数:
foo().setValue(1); // 可以编译,但该临时值在这个完整的表达式结束后会被抛弃
// 下述代码无法编译,cfoo() 返回 const 右值,因此其
// 成员变量是 const 授权,无法被赋值:
cfoo().value = 1; // 无法编译
// 下述代码无法编译,cfoo() 返回 const 右值,无法调用
// 其非 const 的成员函数:
cfoo().setValue(1); // 无法编译
}
```
#### 返回值:指针与 `const` 指针
`const` 成员函数应该返回指针还是 `const` 指针这个问题,令许多人发现 C++ 的“const 正确性”被瓦解了。该问题源于某些 `const` 成员函数,并不修改它们的内部状态,而是返回成员变量的非 `const` 指针。单纯返回一个指针并不会影响对象对外可见的状态,也不会修改它正在维护的状态。但这会令程序员获得间接地修改对象数据的权限。
下述范例展示了通过 `const` 成员函数返回的非 `const` 指针来规避不可变性的诸多方法之一:
```c++
QVariant CustomWidget::inputMethodQuery(Qt::InputMethodQuery query) const {
moveBy(10, 10); // 无法编译!
window()->childAt(mapTo(window(), rect().center()))->moveBy(10, 10); // 可以编译!
}
```
返回 `const` 指针的函数,至少在一定程度上,避免了此类(可能并不希望/非预期的)副作用。但哪些函数会考虑返回 `const` 指针,或一组 `const` 指针?若我们使用 const正确 的方案,即令任何 `const` 成员函数返回成员变量(或一组成员变量的指针)时都是用 `const` 指针形式。很不幸的是,实际中这会造就无法使用的 API:
```c++
QGraphicsScene scene;
// … 初始化场景
foreach (const QGraphicsItem *item, scene.items()) {
item->setPos(qrand() % 500, qrand() % 500); // 无法编译!item 是 const 指针
}
```
`QGraphicsScene::items()` 是 `const` 成员函数,这可能会让人觉得应该返回 `const` 指针。
在 Qt 中,我们近乎只使用非 `const` 的模式。我们选择了实用主义之路:返回 `const` 指针更容易导致 `const_cast` 的过度使用,这比滥用返回的非 `const` 指针引发的问题更加频繁。
#### 返回类型:值 或 `const` 引用?
如果我们在返回对象时还保留了它的副本,返回 `const` 引用是最快的方法;然而,这在我们之后打算重构这个类时成为了限制(使用 d 指针惯用法,我们可以在任何时候修改 Qt 类的内存结构;但我们无法在不破坏二进制兼容性的前提下,将函数签名从 `const QFoo&` 改为 `QFoo`)。出于此原因,我们通常返回 `QFoo` 而非 `const QFoo&`,除了性能极端敏感,而重构并不是问题的少数场合(例如 `QList::at()`)。
#### `const` 与 对象的状态
`const`正确性 是 C 中的一场“圣战”(译者注:原文为 `vi-emacs discussion`),因为该原则在一些领域(如基于指针的函数)中是失效了。
但 `const` 成员函数的常规含义是值不会修改一个类对外可见的状态,状态在此处值“我自己的和我负责的”。这并不意味着 `const` 成员函数会改变它们自己的私有成员变量,但也不代表不能这么做。但通常来说,`const` 成员函数不会产生可见的副作用。例如:
```c++
QSize size = widget->sizeHint(); // const
widget->move(10, 10); // 非 const
```
代理对象负责处理对另一个对象的绘制工作,它的状态包含了它负责的内容,也就是包含它的绘制目标的状态。请求代理进行绘制是具有副作用的:这会改变正在被绘制的设备的外观(也意味着状态)。正因如此,令 `paint()` 成为 `const` 并不合理。任何视图控件或 `QIcon` 的 `paint()` 作为 `const` 都很不合理。没人会在 `const` 成员函数中去调用 `QIcon::paint()`,除非他们明确地像规避当前函数的 `const` 性质。而在这种场景中,显示的 `const_cast` 会是更好的选择:
```c++
// QAbstractItemDelegate::paint 是 const
void QAbstractItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
// QGraphicsItem::paint 不是 const
void QGraphicsItem::paint(QPainter &painter, const QStyleOptionGraphicsItem &option, QWidget &widget = 0)
```
`const` 关键字不会为你**做任何事**,考虑将其移除,而非为一个成员函数提供 `const`/非 `const` 的重载版本。
## API Semantics and Documentation
What should you do when you pass -1 to a function? etc…
Warnings/fatals/etc
APIs need quality assurance. The first revision is never right; you must test it. Make use cases by looking at code which uses this API and verify that the code is readable.
Other tricks include having somebody else use the API with or without documentation and documenting the class (both the class overview and the individual functions).
## The Art of Naming
Naming is probably the single most important issue when designing an API. What should the classes be called? What should the member functions be called?
### General Naming Rules
A few rules apply equally well to all kinds of names. First, as I mentioned earlier, do not abbreviate. Even obvious abbreviations such as "prev" for "previous" don't pay off in the long run, because the user must remember which words are abbreviated.
Things naturally get worse if the API itself is inconsistent; for example, Qt 3 has activatePreviousWindow() and fetchPrev(). Sticking to the "no abbreviation" rule makes it simpler to create consistent APIs.
Another important but more subtle rule when designing classes is that you should try to keep the namespace for subclasses clean. In Qt 3, this principle wasn't always followed. To illustrate this, we will take the example of a QToolButton. If you call name(), caption(), text(), or textLabel() on a QToolButton in Qt 3, what do you expect? Just try playing around with a QToolButton in Qt Designer:
- The name property is inherited from QObject and refers to an internal object name that can be used for debugging and testing.
- The caption property is inherited from QWidget and refers to the window title, which has virtually no meaning for QToolButtons, since they usually are created with a parent.
- The text property is inherited from QButton and is normally used on the button, unless useTextLabel is true.
- The textLabel property is declared in QToolButton and is shown on the button if useTextLabel is true.
In the interest of readability, name is called objectName in Qt 4, caption has become windowTitle, and there is no longer any textLabel property distinct from text in QToolButton.
Documenting is also a good way of finding good names when you get stuck: just try to document the item (class, function, enum value, etc.) and use your first sentence as inspiration. If you cannot find a precise name, this is often a sign that the item shouldn't exist. If everything else fails and you are convinced that the concept makes sense, invent a new name. This is, after all, how "widget", "event", "focus", and "buddy" came to be.
### Naming Classes
Identify groups of classes instead of finding the perfect name for each individual class. For example, All the Qt 4 model-aware item view classes are suffixed with View (QListView, QTableView, and QTreeView), and the corresponding item-based classes are suffixed with Widget instead (QListWidget, QTableWidget, and QTreeWidget).
### Naming Enum Types and Values
The guiding principle is to avoid name clashes between enum values and to ensure readability code with reasonable verbosity.
#### Enums in Qt/global namespace
New enums in the Qt namespace should always use scoped/strong enumerators by default. The scoping/strong typing ensures that there is no conflict if the same enum value name is used multiple times:
```
```
`namespace Qt { enum class Color { Blue, Orange, Yellow }; `` enum class FavoriteColor { Yellow, Orange }; } ``Color yellow = Qt::Color::Yellow; FavoriteColor yellow2 = Qt::FavoriteColor::Yellow; yellow2 = Qt::Orange; // error ```
``
When using scoped enums additional naming rules (repeating of enum type name inside enum value name) for are not necessary.
#### Enums in classes
Enums inside a class do not have the same problem of names clashing, as they are already namespaced within the class.
There are still reasons to prefer scoped enums inside classes, but this should be decided on a case by case basis.
If the enum values have a clear relation to the parent class, prefer un-scoped enums:
```
```
`class TouchPoint { enum State { Pressed, Held, Released }; ``}; // The context is clear when used outside the class if (point.state() == TouchPoint::Pressed) `` ... ``// As well as when used inside it if (state() == Pressed) `` ... ```
``
Using scoped enums in this case would add redundant line noise:
```
if (point.state() == TouchPoint::State::Pressed)
```
` ... ``if (state() == State::Pressed) `` ... ```
``
Note that the context where the enum is used, such as the name of the getter that returns the enum value, might be enough information to make a scoped enum redundant.
If the enum values do not have a natural relation to the class name, prefer scoped enums, e.g.:
```
```
`class QSslCertificate { enum class PatternSyntax { RegularExpression, Wildcard, FixedString }; ``}; if (syntax == PatternSyntax::Wildcard) `` ... ```
`` Another option to avoid the name clash instead of scoped/strong enums is to embedded the enum type name into each enum value. This method was extensively used in Qt 4 before scoped/strong enums were available.
```
```
`class Widget { enum Corner { TopLeftCorner, BottomRightCorner, … }; }; ``tabWidget->setCornerWidget(widget, Widget::TopLeftCorner); ```
``
#### Enums in flags
When enumerator values can be OR'd together and be used as flags, the traditional solution is to store the result of the OR in an int, which isn't type-safe. Qt offers a template class QFlags<T>, where T is the enum type. For convenience, Qt provides typedefs for the flag type names, so you can type Qt::Alignment instead of QFlags<Qt::AlignmentFlag>.
By convention, we give the enum type a singular name (since it can only hold one flag at a time) and the "flags" type a plural name. For example:
```
enum RectangleEdge { LeftEdge, RightEdge, … };
typedef QFlags<RectangleEdge> RectangleEdges;
```
In some cases, the "flags" type has a singular name. In that case, the enum type is suffixed with Flag:
```
enum AlignmentFlag { AlignLeft, AlignTop, … };
typedef QFlags<AlignmentFlag> Alignment;
```
### Naming Functions and Parameters
The number one rule of function naming is that it should be clear from the name whether the function has side-effects or not. In Qt 3, the const function QString::simplifyWhiteSpace() violated this rule, since it returned a QString instead of modifying the string on which it is called, as the name suggests. In Qt 4, the function has been renamed QString::simplified().
Parameter names are an important source of information to the programmer, even though they don't show up in the code that uses the API. Since modern IDEs show them while the programmer is writing code, it's worthwhile to give decent names to parameters in the header files and to use the same names in the documentation.
### Naming Boolean Getters, Setters, and Properties
Finding good names for the getter and setter of a bool property is always a special pain. Should the getter be called checked() or isChecked()? scrollBarsEnabled() or areScrollBarEnabled()?
In Qt 4, we used the following guidelines for naming the getter function:
- Adjectives are prefixed with
is-
. Examples:
- `isChecked()`
- `isDown()`
- `isEmpty()`
- `isMovingEnabled()`
- However, adjectives applying to a plural noun have no prefix:
- `scrollBarsEnabled(), not areScrollBarsEnabled()`
- Verbs have no prefix and don't use the third person (-s):
- `acceptDrops(), not acceptsDrops()`
- `allColumnsShowFocus()`
- Nouns generally have no prefix:
- `autoCompletion(), not isAutoCompletion()`
- `boundaryChecking()`
- Sometimes, having no prefix is misleading, in which case we prefix with
is-
:
- `isOpenGLAvailable(), not openGL()`
- `isDialog(), not dialog()`
The name of the setter is derived from that of the getter by removing any is prefix and putting a set at the front of the name; for example, setDown() and setScrollBarsEnabled(). The name of the property is the same as the getter, but without the is prefix.
## Avoiding Common Traps
### The Convenience Trap
It is a common misconception that the less code you need to achieve something, the better the API. Keep in mind that code is written more than once but has to be understood over and over again. For example,
```
```
`QSlider *slider = new QSlider(12, 18, 3, 13, Qt::Vertical, 0, "volume"); ```
``
is much harder to read (and even to write) than
```
```
`QSlider *slider = new QSlider(Qt::Vertical); slider->setRange(12, 18); slider->setPageStep(3); slider->setValue(13); slider->setObjectName("volume"); ```
``
### The Boolean Parameter Trap
Boolean parameters often lead to unreadable code. In particular, it's almost invariably a mistake to add a bool parameter to an existing function. In Qt, the traditional example is repaint(), which takes an optional bool parameter specifying whether the background should be erased (the default) or not. This leads to code such as
```
```
`widget->repaint(false); ```
``
which beginners might read as meaning, "Don't repaint!"
The thinking is apparently that the bool parameter saves one function, thus helping reducing the bloat. In truth, it adds bloat; how many Qt users know by heart what each of the next three lines does?
```
```
`widget->repaint(); widget->repaint(true); widget->repaint(false); ```
``
A somewhat better API might have been
```
```
`widget->repaint(); widget->repaintWithoutErasing(); ```
``
In Qt 4, we solved the problem by simply removing the possibility of repainting without erasing the widget. Qt 4's native support for double buffering made this feature obsolete.
Here are a few more examples:
```
```
`widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding, true); textEdit->insert("Where's Waldo?", true, true, false); QRegExp rx("moc_'***.c??", false, true);\*** ```
``
An obvious solution is to replace the bool parameters with enum types. This is what we've done in Qt 4 with case sensitivity in QString. Compare:
```
```
`str.replace("USER", user, false); // Qt 3 str.replace("USER", user, Qt::CaseInsensitive); // Qt 4 ```
``
### The Copy Cat Trap
## Case Studies
### QProgressBar
To show some of these concepts in practice, we'll study the QProgressBar API of Qt 3 and compare it to the Qt 4 API. In Qt 3:
```
```
`class QProgressBar : public QWidget { … public: int totalSteps() const; int progress() const; ``const QString &progressString() const; bool percentageVisible() const; void setPercentageVisible(bool); ``void setCenterIndicator(bool on); bool centerIndicator() const; ``void setIndicatorFollowsStyle(bool); bool indicatorFollowsStyle() const; ``public slots: void reset(); virtual void setTotalSteps(int totalSteps); virtual void setProgress(int progress); void setProgress(int progress, int totalSteps); ``protected: virtual bool setIndicator(QString &progressStr, int progress, int totalSteps); … }; ```
``
The API is quite complex and inconsistent; for example, it's not clear from the naming that reset(), setTotalSteps(), and setProgress() are tightly related.
The key to improve the API is to notice that QProgressBar is similar to Qt 4's QAbstractSpinBox class and its subclasses, QSpinBox, QSlider and QDial. The solution? Replace progress and totalSteps with minimum, maximum and value. Add a valueChanged() signal. Add a setRange() convenience function.
The next observation is that progressString, percentage and indicator really refer to one thing: the text that is shown on the progress bar. Usually the text is a percentage, but it can be set to anything using the setIndicator() function. Here's the new API:
```
```
`virtual QString text() const; void setTextVisible(bool visible); bool isTextVisible() const; ```
``
By default, the text is a percentage indicator. This can be changed by reimplementing text().
The setCenterIndicator() and setIndicatorFollowsStyle() functions in the Qt 3 API are two functions that influence alignment. They can advantageously be replaced by one function, setAlignment():
```
```
`void setAlignment(Qt::Alignment alignment); ```
``
If the programmer doesn't call setAlignment(), the alignment is chosen based on the style. For Motif-based styles, the text is shown centered; for other styles, it is shown on the right hand side.
Here's the improved QProgressBar API:
```
```
`class QProgressBar : public QWidget { … public: void setMinimum(int minimum); int minimum() const; void setMaximum(int maximum); int maximum() const; void setRange(int minimum, int maximum); int value() const; ``virtual QString text() const; void setTextVisible(bool visible); bool isTextVisible() const; Qt::Alignment alignment() const; void setAlignment(Qt::Alignment alignment); ``public slots: void reset(); void setValue(int value); ``signals: void valueChanged(int value); … }; ```
``
### QAbstractPrintDialog & QAbstractPageSizeDialog
Qt 4.0 saw the apparition of two classes QAbstractPrintDialog and QAbstractPageSizeDialog that served as base classes for QPrintDialog and QPageSizeDialog. This served no purpose at all, since none of Qt's APIs take a QAbstractPrint- or -PageSizeDialog pointer as an argument and perform some operation on it. Using qdoc trickery, we've hidden them, but they're the prototypical examples of needless abstract classes.
This is not to say *good* abstraction is wrong, and indeed QPrintDialog probably should have a factory or some other mechanism for changing it- as evidenced by the #ifdef QTOPIA_PRINTDIALOG in its declaration.
### QAbstractItemModel
The details of the problems with model/view in Qt 4 are documented well elsewhere, but an important generalization is that "QAbstractFoo" should not just be the union of all possible subclasses you can think of at the time of writing. Such "union of all things" base classes are almost never a good solution. QAbstractItemModel commits this error - it is really just QTreeOfTablesModel, with the consequently complicated API that causes… and which is then *inherited by all the nicer subclasses*,
Just adding abstraction does not make an API better automatically.
### QLayoutIterator & QGLayoutIterator
In Qt 3, creating a custom layout involved subclassing both QLayout and QGLayoutIterator ("G" stands for generic). A QGLayoutIterator subclass instance pointer was wrapped in a QLayoutIterator, which users could use like any other iterator class. QLayoutIterator made it possible to write code like this:
```
```
`QLayoutIterator it = layout()->iterator(); QLayoutItem **child; while ((child = it.current()) != 0) { if (child->widget() == myWidget) { it.takeCurrent(); return; } ++it; ```
```
}
```
In Qt 4, we killed QGLayoutIterator classes (and their internal subclasses for box and grid layouts) and instead asked the QLayout subclasses to reimplement itemAt(), takeAt(), and count().
### QImageSink
Qt 3 had a whole set of classes that allowed images to be incrementally read and passed to an animation - the QImageSource/Sink/QASyncIO/QASyncImageIO classes. Since all these were ever used for was animated QLabels, it was total overkill.
The lesson is not to add abstraction to aide some very vague future possibility. Keep it simple. When those future things come, it will be a lot easier to factor them into a simple system than into a complex one.
### other Qt3 vs. Qt4?
### QWidget::setWindowModified(bool)
### Q3Url vs. QUrl
### Q3TextEdit vs. QTextEdit
How all those virtual functions went a-goner…
### Qt's Clipping Story (naming of clipping fns)
When you set the clip rect, you actually set a region (should be setClipRegion(QRect) instead of setClipRect()).
(on the right, how it should have been…)
================================================
FILE: Src/A/QAbstractAnimation/QAbstractAnimation.md
================================================
[TOC]
# QAbstractAnimation 类
QAbstractAnimation 是所有的动画相关的基类。
QAbstractAnimation 定义了所有动画类相关的基础功能,通过继承该类,您可以实现动画的其它功能,或者添加自定义的特效。
| 属性| 方法|
| ------: |:------|
| 头文件 | `#include<QAbstractAnimation>` |
| qmake | `QT+=core` |
| 自从 | Qt 4.6 |
|继承|[QObject](../../O/QObject/QObject.md)|
|派生|[QAnimationGroup](../QAnimationGroup/QAnimationGroup.md),[QPauseAnimation](../../P/QPauseAnimation/QPauseAnimation.md),[QVariantAnimation](../../V/QVariantAnimation/QVariantAnimation.md)|
## 公共成员类型
| 类型| 方法|
| :------: |:------|
|enum | [DeletionPolicy](#enum-qabstractanimationdeletionpolicy) { KeepWhenStopped, DeleteWhenStopped } |
|enum | [Direction](#enum-qabstractanimationdirection) { Forward, Backward } |
|enum | [State](#enum-qabstractanimationstate) { Stopped, Paused, Running } |
## 属性
| 属性| 类型 | 属性 | 类型 |
| :------ | ------- | ------- | ------- |
|[currentLoop](#currentloop--const-int)|const int|[duration](#duration--const-int)|const int|
|[currentTime](#currenttime--int)|int|[loopCount](#loopcount--int)|int|
|[direction](#direction--direction)|Direction|[state](#state--const-state)|const State|
## 公共成员函数
| 返回类型 | 函数名|
| ------: |:------|
|| [QAbstractAnimation](#qabstractanimationqabstractanimationqobject-parent--qnullptr)(QObject \**parent* = Q_NULLPTR) |
|virtual | ~[QAbstractAnimation](#virtual-qabstractanimationqabstractanimation)() |
|int | [currentLoop](#currentloop--const-int)() const |
|int | [currentLoopTime](#int-qabstractanimationcurrentlooptime-const)() const |
|int | [currentTime](#currenttime--int)() const |
|Direction | [direction](#direction--direction)() const |
|virtual int | [duration](#pure-virtual-int-qabstractanimationduration-const)() const = 0 |
|QAnimationGroup *| [group](#qanimationgroup-qabstractanimationgroup-const)() const |
|int | [loopCount](#loopcount--int)() const |
|void | [setDirection](#direction--direction)(Direction *direction*) |
|void | [setLoopCount](#loopcount--int)(int *loopCount*) |
|State | [state](#state--const-state)() const |
|int | [totalDuration](#int-qabstractanimationtotalduration-const)() const |
## 公共槽
| 返回类型 | 函数名|
| :------: |:------|
|void | [pause](#slot-void-qabstractanimationpause)() |
|void | [resume](#slot-void-qabstractanimationresume)() |
|void | [setCurrentTime](#currenttime--int)(int *msecs*) |
|void | [setPaused](#slot-void-qabstractanimationsetpausedbool-paused)(bool *paused*) |
|void | [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)(QAbstractAnimation::DeletionPolicy *policy* = KeepWhenStopped) |
|void | [stop](#slot-void-qabstractanimationstop)() |
## 信号
| 返回类型 | 函数名|
| :------: |:------|
|void | [currentLoopChanged](#signal-void-qabstractanimationcurrentloopchangedint-currentloop)(int *currentLoop*) |
|void | [directionChanged](#signal-void-qabstractanimationdirectionchangedqabstractanimationdirection-newdirection)(QAbstractAnimation::Direction *newDirection*) |
|void | [finished](#signal-void-qabstractanimationfinished)() |
|void | [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)(QAbstractAnimation::State *newState*, QAbstractAnimation::State *oldState*) |
## 保护成员函数
| 返回类型 | 函数名|
| :------: |:------|
|virtual void | [updateCurrentTime](#pure-virtual-protected-void-qabstractanimationupdatecurrenttimeint-currenttime)(int *currentTime*) = 0 |
|virtual void | [updateDirection](#virtual-protected-void-qabstractanimationupdatedirectionqabstractanimationdirectionenum-qabstractanimationdirection-direction)(QAbstractAnimation::Direction *direction*) |
|virtual void | [updateState](#virtual-protected-void-qabstractanimationupdatestateqabstractanimationstateenum-qabstractanimationstate-newstate-qabstractanimationstateenum-qabstractanimationstate-oldstate)(QAbstractAnimation::State *newState*, QAbstractAnimation::State *oldState*) |
## 重写保护成员函数
| 返回类型 | 函数名|
| :------: |:------|
|virtual bool | [event](#virtual-protected-bool-qabstractanimationeventqevent-event)(QEvent \**event*) |
## 详细介绍
QAbstractAnimation 定义了所有动画共享的功能。通过继承这个类,您可以创建自定义的动画,并将其插入到动画框架中。
动画的进度的当前时间由当前时间([currentLoopTime](int-qabstractanimationcurrentlooptime-const)())控制,数值从0毫秒开始到其最后的持续时间([duration](#pure-virtual-int-qabstractanimationduration-const)())。该值在动画运行时会自动更新,也可以直接由 [setCurrentTime]()() 来设置。
在任何时候,动画的状态都只有三种:[Running](#enum-qabstractanimationstate)、[Stopped](#enum-qabstractanimationstate) 或 [Paused](#enum-qabstractanimationstate)——由枚举变量 [State](#enum-qabstractanimationstate)定义。可以通过函数 [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)()、[stop](#slot-void-qabstractanimationstop)() 、[pause](#slot-void-qabstractanimationpause)() 或 [resume](#slot-void-qabstractanimationresume)() 来改变当前动画的状态。动画开始时总会重置它的[当前时间]()。若被暂停,则继续播放后会从相同的“当前时间”继续。若动画停止,则无法继续,但会保留“当前时间”(直到再次开始)。QAbstractAnimation 在状态改变时将会发出信号 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)()。
通过设置 [loopCount](#loopcount--int) 属性,动画可以循环任意次数。当动画的时间到达 [duration](#pure-virtual-int-qabstractanimationduration-const)() 时,它将重置当前时间并继续运行。循环数为1(默认值)意味着动画只会播放一次。注意,若 `duration` 为-1,动画将无限播放,直到主动停止;当前时间会无限增长。当当前时间等于 [duration](#pure-virtual-int-qabstractanimationduration-const)() ,并且正在处理最后一次循环时,动画将进入 [Stopped](#enum-qabstractanimationstate) 状态,并发送 [finished]()() 信号。
QAbstractAnimation 为子类提供了纯虚函数来跟踪动画的进度:[duration](#pure-virtual-int-qabstractanimationduration-const)() 和 [updateCurrentTime](#pure-virtual-protected-void-qabstractanimationupdatecurrenttimeint-currenttime)()。[duration](#pure-virtual-int-qabstractanimationduration-const)() 函数用于提供动画的持续时间(如上文所述)。当动画时间变化时,动画框架会调用 [updateCurrentTime](#pure-virtual-protected-void-qabstractanimationupdatecurrenttimeint-currenttime)()。通过重新实现该函数,您可以追踪动画进度。注意:此函数的调用间隔和调用次数均未定义,虽然通常每秒会更新60次。
通过重新实现 [updateState](#virtual-protected-void-qabstractanimationupdatestateqabstractanimationstateenum-qabstractanimationstate-newstate-qabstractanimationstateenum-qabstractanimationstate-oldstate)(),您可以追踪动画状态的改变,这对于不受时间驱动的动画特别有用。
**另请参阅:**[QVariantAnimation](../../V/QVariantAnimation/QVariantAnimation.md),[QPropertyAnimation](../../P/QPropertyAnimation/QPropertyAnimation.md),[QAnimationGroup](../QAnimationGroup/QAnimationGroup.md) 和 [The Animation Framework](../The_Animation_Framework/The_Animation_Framework.md)。
## 成员变量文档
### enum QAbstractAnimation::DeletionPolicy
| 函数| 值| 描述|
| :------: |:------:|:------|
|QAbstractAnimation::KeepWhenStopped| 0|动画停止时不会被删除|
|QAbstractAnimation::DeleteWhenStopped| 1| 动画停止时会被自动删除 |
----------
### enum QAbstractAnimation::Direction
该枚举描述了动画在 [Running](#enum-qabstractanimationstate) 状态时的运行的方向。
| 函数| 值| 描述|
| :------: |:------:|:------|
|QAbstractAnimation::Forward| 0|“当前时间”随时间递增(即从0向终点/duration 移动)|
|QAbstractAnimation::Backward| 1| ”当前时间“随时间递减(即从终点/duration 向0移动) |
----------
### enum QAbstractAnimation::State
该枚举描述了动画的状态。
| 函数| 值| 描述|
| :------: |:------:|:------|
|QAbstractAnimation::Stopped| 0| 动画未运行。这是 [QAbstractAnimation](QAbstractAnimation.md) 的初始状态,也是 [[QAbstractAnimation]](QAbstractAnimation.md) 结束后的状态。除非 [setCurrentTime]()() 被调用,或者调用 [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)() 来启动动画,否则”当前时间“不会改变。 |
|QAbstractAnimation::Paused| 1|动画暂停(即使暂时挂起)。调用 [resume](#slot-void-qabstractanimationresume)() 将恢复动画。|
|QAbstractAnimation::Running| 2|动画运行中。当控制权处于事件循环中时,[QAbstractAnimation](QAbstractAnimation.md) 将会有规律地更新”当前时间“,并在适合地时机调用 [updateCurrentTime](#pure-virtual-protected-void-qabstractanimationupdatecurrenttimeint-currenttime)()。|
## 属性文档
### currentLoop : const int
此属性存储动画当前的循环数。
此属性描述了动画当前的循环数。默认的循环次数为1,所以当前的循环次数永远为0。若循环总数2的,当动画运行超过其 duration 时将重新开始,并将当前时间重置为0,当前循环数置为1,以此类推。
当当前循环变化时,[QAbstractAnimation](QAbstractAnimation.md) 会发出 [currentLoopChanged](#signal-void-qabstractanimationcurrentloopchangedint-currentloop)() 信号。
**存取函数**
| 返回类型 | 函数名 |
| :------: | :---------------------- |
| int | **currentLoop**() const |
**通知信号**
| 返回类型 | 函数名 |
| :------: | :----------------------------------------------------------- |
| void | [currentLoopChanged](#signal-void-qabstractanimationcurrentloopchangedint-currentloop)(int *currentLoop*) |
----------
### currentTime : int
此属性存储动画当前的时间与进度。
此属性描述了动画当前的时间。您可以通过 `setCurrentTime` 函数来修改当前时间,也可以调用 [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)() 让动画运行,当前时间会随动画播放进度自动设置。
动画的当前时间从0开始,在 [totalDuration](#int-qabstractanimationtotalduration-const)() 结束。
**存取函数**
| 返回类型 | 函数名 |
| :------: | :---------------------------- |
| int | **currentTime**() const |
| void | **setCurrentTime**(int msecs) |
**另请参阅:**[loopCount](#loopcount--int) 和 [currentLoopTime](int-qabstractanimationcurrentlooptime-const)()。
----------
### direction : Direction
该属性存储动画在 [Running](#enum-qabstractanimationstate) 状态时的运行方向。
该方向表明了在 [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)() 被调用后,时间是从0向动画时长移动,还是从持续时间向0移动。
默认方向为 [Forward](#enum-qabstractanimationdirection)。
**存取函数**
| 返回类型 | 函数名|
| :------: |:------|
|Direction | **direction**() const |
|void | **setDirection**(Direction *direction*) |
**通知信号**
| 返回类型 | 函数名|
| :------: |:------|
|void | [directionChanged](#signal-void-qabstractanimationdirectionchangedqabstractanimationdirection-newdirection)(QAbstractAnimation::Direction *newDirection*) |
----------
### duration : const int
该属性存储动画的持续时间。
如果 `duration` 为-1,则表示 `duration` 未定义,此时动画将会忽略 `loopCount` 属性。
**存取函数**
| 属性| 函数名|
| :------: |:------|
|virtual int | [duration](#pure-virtual-int-qabstractanimationduration-const)() const = 0 |
----------
### loopCount : int
该属性存储动画的循环次数。
此属性用整形描述了动画的循环次数。默认值为1,表示该动画只播放一次,然后停止。通过修改其值,动画会改变循环的次数。当值为0时,动画完全不会运行;当值为-1时,动画将会永远循环直到主动停止。如果动画未设置 `duration` 属性则无法循环,即只会播放一次。
**存取函数**
| 属性| 函数名|
| :------: |:------|
|int |**loopCount**() const|
|void | **setLoopCount**(int *loopCount*) |
----------
### state : const State
动画状态。
此属性描述了动画的当前状态。当动画状态改变时,[QAbstractAnimation](QAbstractAnimation.md) 会发射 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)() 信号。
**存取函数**
| 属性| 函数名|
| :------: |:------|
|State | **state**() const |
**通知信号**
| 属性| 函数名|
| :------: |:------|
|void | [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)(QAbstractAnimation::State *newState*, QAbstractAnimation::State *oldState*) |
## 成员函数文档
### QAbstractAnimation::**QAbstractAnimation**([QObject](../../O/QObject/QObject.md) *\*parent* = Q_NULLPTR)
构造 QAbstractAnimation 基类,并将 `parent` 参数传递给 [QObject](../../O/QObject/QObject.md) 的构造函数。
**另请参阅:**[QVariantAnimation](../../V/QVariantAnimation/QVariantAnimation.md) 和 [QAnimationGroup](../QAnimationGroup/QAnimationGroup.md)
----------
### **[signal]** void QAbstractAnimation::**currentLoopChanged**(int *currentLoop*)
每当当前循环发生变化时,[QAbstractAnimation](QAbstractAnimation.md) 会发射该信号。`currentLoop` 为当前循环。
**注意:** 属性 `currentLoop` 的通知信号。
**另请参阅:**[currentLoop](#currentloop--const-int)() 和 [loopCount](#loopcount--int)()。
----
### **[signal]** void QAbstractAnimation::**directionChanged**([QAbstractAnimation::Direction](#enum-qabstractanimationdirection) *newDirection*)
每当方向改变时,[QAbstractAnimation](QAbstractAnimation.md) 会发射该信号。`newDirection` 为新方向。
**注意:** 属性 `direction` 的通知信号。
**另请参阅:**[direction](#direction--direction)()。
----
### **[signal]** void QAbstractAnimation::**finished**()
在动画停止并到达终点之后发送此信号。
该信号在 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)() 之后发射。
**另请参阅:**[stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)()。
----
### **[slot]** void QAbstractAnimation::**pause**()
暂停动画。当动画暂停时,[state](#state--const-state)() 返回 [Paused](#enum-qabstractanimationstate)。在调用 [resume](#slot-void-qabstractanimationresume)() 或 [start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)() 前,[currentTime](#currenttime--int)() 的值将会保持不变。若想从当前时间继续,则调用 [resume](#slot-void-qabstractanimationresume)()函数。
**另请参阅:**[start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)(),[state](#state--const-state)() 和 [resume](#slot-void-qabstractanimationresume)()。
----
### **[slot]** void QAbstractAnimation::**resume**()
暂停后恢复动画。当动画恢复时,会发射会发出 resumed() 信号和 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)() 信号。当前时间不会变化。
**另请参阅:**[start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped),[pause](#slot-void-qabstractanimationpause)() 和 [state](#state--const-state)()。
----
### **[slot]** void QAbstractAnimation::**setPaused**(bool *paused*)
若 `paused` 为 `true`,则暂停动画。若 `pause` 为 `false`,则恢复动画播放。
**另请参阅:**[state](#state--const-state)(),[pause](#slot-void-qabstractanimationpause)() 和 [resume](#slot-void-qabstractanimationresume)()。
----
### **[slot]** void QAbstractAnimation::**start**([QAbstractAnimation::DeletionPolicy](#enum-qabstractanimationdeletionpolicy) *policy* = KeepWhenStopped)
开始动画。`policy` 参数表示动画在结束后是否会被删除。动画启动时,会发射 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)() 信号,[state](#state--const-state)() 会返回 `Running`。当控制权回到事件循环时,动画会自动播放,并随播放进度周期性调用 [updateCurrentTime](#pure-virtual-protected-void-qabstractanimationupdatecurrenttimeint-currenttime)(),
若动画当前已被停止或者已经结束,调用 `start()` 将会充值动画并从头开始。当动画到达终点时,动画将会停止;或者当其循环次数大于1,则会从头开始。
若动画已经在运行中,此函数不会有任何操作。
**另请参阅:**[stop](#slot-void-qabstractanimationstop)() 和 [state](#state--const-state)()。
----
### **[signal]** void QAbstractAnimation::**stateChanged**([QAbstractAnimation::State](#enum-qabstractanimationstate) *newState*, [QAbstractAnimation::State](#enum-qabstractanimationstate) *oldState*)
每当动画的状态从 `oldState` 变为 `newState` 时,[QAbstractAnimation](QAbstractAnimation.md) 会发射此信号。此信号会在虚函数 [updateState](#virtual-protected-void-qabstractanimationupdatestateqabstractanimationstateenum-qabstractanimationstate-newstate-qabstractanimationstateenum-qabstractanimationstate-oldstate)()被调用后发射。
**注意:** 属性 [state](#state--const-state) 的通知信号。
**另请参阅:**[updateState](#virtual-protected-void-qabstractanimationupdatestateqabstractanimationstateenum-qabstractanimationstate-newstate-qabstractanimationstateenum-qabstractanimationstate-oldstate)()。
----
### **[slot]** void QAbstractAnimation::**stop**()
停止动画。当动画停止时,会发射 [stateChanged](#signal-void-qabstractanimationstatechangedqabstractanimationstate-newstate-qabstractanimationstate-oldstate)() 信号,[state](#state--const-state)() 返回 `Stopped`。当前时间不会变化。
若动画到达终点后自动结束(比如 [currentLoopTime](int-qabstractanimationcurrentlooptime-const)() == [duration](#pure-virtual-int-qabstractanimationduration-const)() 或者 [currentLoop](#currentloop--const-int)() > [loopCount](#loopcount--int)() - 1),则会发射 [finished](#signal-void-qabstractanimationfinished)() 信号。
**另请参阅:**[start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)() 和 [state](#state--const-state)()。
----
### **[virtual]** QAbstractAnimation::**~QAbstractAnimation**()
若在运行中则停止动画,然后销毁 [QAbstractAnimation](QAbstractAnimation.md)。若当前动画是 [QAnimationGroup](../QAbstractAnimation/QAnimationGroup.md) 的一部分,则会在销毁前被自动移除。
----------
### int QAbstractAnimation::**currentLoopTime**() const
返回当前循环中的当前时间。它的范围为0到 [duration](#pure-virtual-int-qabstractanimationduration-const)()。
**另请参阅:** [duration](#pure-virtual-int-qabstractanimationduration-const)() 和 [currentTime](#currenttime--int)()。
----------
### **[pure virtual]** int QAbstractAnimation::**duration**() const
此纯虚函数返回动画持续时间,并定义 [QAbstractAnimation](QAbstractAnimation.md) 应该多久更新一次当前时间。持续时间是本地的,并且不包括循环总数。
返回值-1表示动画没有定义持续时间,动画将永远运行下去,直到被主动停止。这对于非时间驱动的动画或者无法预测其持续时间的动画(例如游戏中事件驱动的音频回放)十分有用。
若该动画是并行的 [QAbstractAnimation](../QAbstractAnimation/QAbstractAnimation.md) 是并行的,则持续时间是所有动画中最长的。若此动画是顺序的 [QAnimationGroup](../QAnimationGroup/QAnimationGroup.md),则持续时间是所有动画的总和。
**注意:**`duration` 属性的获取函数。
**另请参阅:**[loopCount](#loopcount--int)()。
----------
### **[virtual protected]** bool QAbstractAnimation::**event**([QEvent](../../E/QEvent/QEvent.md) \**event*)
[QObject::event](../../O/QObject/QObject.md#event)(QEvent *e) 的重新实现。
----------
### [QAnimationGroup](../QAnimationGroup/QAnimationGroup.md) \*QAbstractAnimation::**group**() const
若此动画是 [QAnimationGroup](../QAnimationGroup/QAnimationGroup.md) 的一部分,则会返回该动画组的指针,否则返回`nullptr`。
**另请参阅:**[QAnimationGroup::addAnimation](../QAnimationGroup/QAnimationGroup.md#addAnimation)()。
----------
### int QAbstractAnimation::**totalDuration**() const
返回动画的有效持续时间的综合,包含循环次数。
**另请参阅:**[duration](#pure-virtual-int-qabstractanimationduration-const)() 和 [currentTime](#currenttime--int)()。
----------
### **[pure virtual protected]** void QAbstractAnimation::**updateCurrentTime**(int *currentTime*)
此虚函数会当动画的 `currentTime` 每次发生变化时被调用。
**另请参阅:**[updateState](#virtual-protected-void-qabstractanimationupdatestateqabstractanimationstateenum-qabstractanimationstate-newstate-qabstractanimationstateenum-qabstractanimationstate-oldstate)()。
----------
### **[virtual protected]** void QAbstractAnimation::**updateDirection**([QAbstractAnimation::Direction](#enum-qabstractanimationdirection) *direction*)
此虚函数会在 [QAbstractAnimation](QAbstractAnimation.md) 的播放方向改变时被调用。参数 `direction` 表示新的方向。
**另请参阅:**[setDirection]()(),[direction](#direction--direction)()。
----------
### **[virtual protected]** void QAbstractAnimation::**updateState**([QAbstractAnimation::State](#enum-qabstractanimationstate) *newState*, [QAbstractAnimation::State](#enum-qabstractanimationstate) *oldState*)
此虚函数会在动画的状态改变从 `oldState` 切换为 `newState` 时被调用。
**另请参阅:**[start](#slot-void-qabstractanimationstartqabstractanimationdeletionpolicy-policy--keepwhenstopped)(),[stop](#slot-void-qabstractanimationstop)(),[pause](#slot-void-qabstractanimationpause)() 和 [resume](#slot-void-qabstractanimationresume)()。
================================================
FILE: Src/A/QAbstractAudioDeviceInfo/QAbstractAudioDeviceInfo.md
================================================
[TOC]
# **QAbstractAudioDeviceInfo类**
----------
## **QAbstractAudioDeviceInfo是音频后端的基类**
| 属性| 方法|
| ------: |:------|
| Header: | `#include<QAbstractAudioDeviceInfo>` |
| qmake: | QT += multimedia|
|Inherits:|QObject|
----------
## **简述**
### **公共功能**
| 类型| 方法|
| ------: |:------|
|virtual QString| deviceName() const = 0|
|virtual bool| isFormatSupported(const QAudioFormat &format) const = 0|
|virtual QAudioFormat| preferredFormat() const = 0|
|virtual QList<QAudioFormat::Endian>| supportedByteOrders() = 0|
|virtual QList<int>| supportedChannelCounts() = 0|
|virtual QStringList| supportedCodecs() = 0|
|virtual QList<int>| supportedSampleRates() = 0|
|virtual QList<int>| supportedSampleSizes() = 0|
|virtual QList<QAudioFormat::SampleType>| supportedSampleTypes() = 0|
----------
## **详细说明**
----------
QAbstractAudioDeviceInfo是音频后端的基类。
该类实现了QAudioDeviceInfo的音频功能,即QAudioDeviceInfo类中会保留一个QAbstractAudioDeviceInfo,并对其进行调用。关于QAbstractAudioDeviceInfo的实现的其它功能,您可以参考QAudioDeviceInfo的类与函数文档
----------
### **成员函数文档**
----------
**QString QAbstractAudioDeviceInfo::deviceName() const [纯虚函数]**
返回音频设备名称
----------
**bool QAbstractAudioDeviceInfo::isFormatSupported(const QAudioFormat &format) const [纯虚函数]**
传入参数QAudioFormat(音频流)类,如果QAbstractAudioDeviceInfo支持的话,返回true(真是不好翻译)
----------
**QAudioFormat QAbstractAudioDeviceInfo::preferredFormat() const [纯虚函数]**
返回QAbstractAudioDeviceInfo更加倾向于使用的音频流。
----------
**QList<QAudioFormat::Endian> QAbstractAudioDeviceInfo::supportedByteOrders() [纯虚函数]**
返回当前支持可用的字节顺序(QAudioFormat :: Endian)列表
----------
**QList<int> QAbstractAudioDeviceInfo::supportedChannelCounts() [纯虚函数]**
返回当前可用的通道(应该是这样翻译)列表
----------
**QStringList QAbstractAudioDeviceInfo::supportedCodecs() [纯虚函数]**
返回当前可用编解码器的列表
----------
**QList<int> QAbstractAudioDeviceInfo::supportedSampleRates() [纯虚函数]**
返回当前可用的采样率列表。(突然发现Google翻译真心吊啊)
----------
**QList<int> QAbstractAudioDeviceInfo::supportedSampleSizes() [纯虚函数]**
返回当前可用的样本大小列表。
----------
**QList<QAudioFormat::SampleType> QAbstractAudioDeviceInfo::supportedSampleTypes() [纯虚函数]**
返回当前可用样本类型的列表。
================================================
FILE: Src/A/QAbstractAudioInput/QAbstractAudioInput.md
================================================
[TOC]
# **QAbstractAudioInput类**
----------
## **QAbstractAudioInput类为QAudioInput类提供了访问音频设备的方法。(通过插件的形式)**
| 属性| 方法|
| ------: |:------|
|Header:|`#include <QAbstractAudioInput>`|
|qmake: |QT += multimedia|
|Inherits:| QObject|
----------
## **简述**
### **公有的函数**
| 类型| 方法|
| ------: |:------|
|virtual int| [bufferSize()](#int-qabstractaudioinputbuffersize-const-纯虚函数) const = 0|
|virtual int| [bytesReady()](#int-qabstractaudioinputbytesReady-const-纯虚函数) const = 0|
|virtual qint64| [elapsedUSecs()](#qint64-qabstractaudioinputelapsedusecs-const-纯虚函数) const = 0|
|virtual QAudio::Error| [error()](#qaudioerror-qabstractaudioinputerror-const-纯虚函数) const = 0|
|virtual QAudioFormat| [format()](#qaudioformat-qabstractaudioinputformat-const-纯虚函数) const = 0|
|virtual int| [notifyInterval()](#int-qabstractaudioinputnotifyinterval-const-纯虚函数) const = 0|
|virtual int| [periodSize()](#int-qabstractaudioinputperiodsize-const-纯虚函数) const = 0|
|virtual qint64| processedUSecs() const = 0|
|virtual void| reset() = 0|
|virtual void| resume() = 0|
|virtual void| setBufferSize(int value) = 0|
|virtual void |setFormat(const QAudioFormat &fmt) = 0|
|virtual void| setNotifyInterval(int ms) = 0|
|virtual void| setVolume(qreal) = 0|
|virtual void |start(QIODevice *device) = 0|
|virtual QIODevice*| start() = 0|
|virtual QAudio::State| state() const = 0|
|virtual void |stop() = 0|
|virtual void| suspend() = 0|
|virtual qreal |volume() const = 0|
----------
### **信号**
| 类型| 方法|
| ------: |:------|
|void| errorChanged(QAudio::Error error)|
|void| notify()|
|void| stateChanged(QAudio::State state)|
----------
## **详细描述**
`QAbstractAudioInput`类为QAudioInput类提供了访问音频设备的方法。(通过插件的形式)
`QAudioDeviceInput`类中保留了一个`QAbstractAudioInput`的实例,并且调用的函数与`QAbstractAudioInput`的一致。
> 译者注:也就是说QAudioDeviceInput调用的函数实际上是QAbstractAudioInput的函数,就封装了一层相同函数名吧。可以自己看看源码。)
这意味着QAbstractAudioInput是实现音频功能的。有关功能的描述,可以参考QAudioInput类。
另见QAudioInput函数
----------
## **成员函数文档**
----------
### int QAbstractAudioInput::bufferSize() const [纯虚函数]
以毫秒为单位返回音频缓冲区的大小
----------
### int QAbstractAudioInput::bytesReady() const [纯虚函数]
以字节(bytes)为单位返回可读取的音频数据量
----------
### qint64 QAbstractAudioInput**::elapsedUSecs() const [纯虚函数]
返回调用start()函数以来的毫秒数,包括空闲时间与挂起状态的时间
----------
### QAudio::Error QAbstractAudioInput::error() const [纯虚函数]
返回错误的状态
----------
### void QAbstractAudioInput::errorChanged(QAudio::Error error) [信号signal]
当错误状态改变时,该信号被发射
----------
### QAudioFormat QAbstractAudioInput::format() const [纯虚函数]
返回正在使用的QAudioFormat(这个类是储存音频流相关的参数信息的)
另参见setFormat()函数
----------
### void QAbstractAudioInput::notify() [信号signal]
当音频数据的x ms通过函数setNotifyInterval()调用之后,这个信号会被发射。
----------
### int QAbstractAudioInput::notifyInterval() const [纯虚函数]
以毫秒为单位返回通知间隔
----------
### int QAbstractAudioInput::periodSize() const [纯虚函数]
以字节为单位返回其周期
----------
### qint64 QAbstractAudioInput::processedUSecs() const [纯虚函数]
返回自start()函数被调用之后处理的音频数据量(以毫秒为单位)
----------
### void QAbstractAudioInput::reset() [纯虚函数]
将所有音频数据放入缓冲区,并将缓冲区重置为零
----------
### void QAbstractAudioInput::resume() [纯虚函数]
在音频数据*暂停*后继续处理
----------
### void QAbstractAudioInput::setBufferSize(int value) [纯虚函数]
将音频缓冲区大小设置为value大小(以毫秒为单位)
另参阅bufferSize()函数
----------
### void QAbstractAudioInput::setFormat(const QAudioFormat &fmt) [纯虚函数]
设置音频格式,设置格式的时候只能在QAudio的状态为StoppedState时(QAudio::StoppedState)
----------
### void QAbstractAudioInput::setNotifyInterval(int ms) [纯虚函数]
设置发送notify()信号的时间间隔。这个ms时间间隔与操作系统平台相关,并不是实际的ms数。
----------
### void QAbstractAudioInput::setVolume(qreal) [纯虚函数]
另见volume()函数
(设置这里应该是设置音量的值,Volume在英文中有音量的意思,官方文档这里根本就没有任何说明,说去参考valume()函数,可是valume()说又去参考SetValume()函数,这是互相甩锅的节奏么???坑爹啊!!!)
----------
### void QAbstractAudioInput::start(QIODevice *device) [纯虚函数]
使用输入参数```QIODevice *device```来传输数据
----------
### QIODevice *QAbstractAudioInput::start() [纯虚函数]
返回一个指向正在用于正在处理数据QIODevice的指针。这个指针可以用来直接读取音频数据。
----------
### QAudio::State QAbstractAudioInput::state() const [纯虚函数]
返回处理音频的状态
----------
### void QAbstractAudioInput::stateChanged(QAudio::State state) [信号signal]
当设备状态改变时,会发出这个信号
----------
### void QAbstractAudioInput::stop() [纯虚函数]
停止音频输入(因为这是个QAbstractAudioInput类啊,输入类啊,暂时这么解释比较合理。)
----------
### void QAbstractAudioInput::suspend() [纯虚函数]
停止处理音频数据,保存缓冲的音频数据
----------
### qreal QAbstractAudioInput::volume() const [纯虚函数]
另见setVolume()(内心os:参考我解释setVolume()函数的说明,这里应该是返回其音量)
----------
================================================
FILE: Src/A/QAbstractAudioOutput/QAbstractAudioOutput.md
================================================
[TOC]
#**QAbstractAudioOutput类**
----------
## **QAbstractAudioOutput类是音频后端的基类**
| 属性 | 方法|
|------:|:------|
|头文件包含:|``` #include <QAbstractAudioOutput>```|
|qmake写法:| QT += multimedia|
|继承:| QObject|
----------
## **简述**
### **public函数**
| 类型 | 函数名|
|------:|:------|
|virtual int| bufferSize() const = 0|
|virtual int| bytesFree() const = 0|
|virtual QString| category() const|
|virtual qint64| elapsedUSecs() const = 0|
|virtual QAudio::Error| error() const = 0|
|virtual QAudioFormat| format() const = 0|
|virtual int |notifyInterval() const = 0|
|virtual int|periodSize() const = 0|
|virtual qint64| processedUSecs() const = 0|
|virtual void |reset() = 0|
|virtual void |resume() = 0|
|virtual void| setBufferSize(int value) = 0|
|virtual void| setCategory(const QString &)|
|virtual void| setFormat(const QAudioFormat &fmt) = 0|
|virtual void| setNotifyInterval(int ms) = 0|
|virtual void| setVolume(qreal volume)|
|virtual void| start(QIODevice *device) = 0|
|virtual QIODevice *| start() = 0|
|virtual QAudio::State| state() const = 0|
|virtual void| stop() = 0|
|virtual void| suspend() = 0|
|virtual qreal| volume() const|
----------
### **信号**
| 类型 | 函数名|
|------:|:------|
|void | errorChanged(QAudio::Error error)|
|void | notify()|
|void | stateChanged(QAudio::State state)|
----------
## **详细描述**
QAbstractAudioOutput类是音频后端的基类。
QAbstractAudioOutput类是QAudioOutput类的实现类。QAudioOutput的实现实际上是调用的QAbstractAudioOutput类,有关实现相关的功能,请参考QAudioOutput()类中的函数说明。
----------
## **成员函数**
----------
**int QAbstractAudioOutput::bufferSize() const [纯虚函数]**
以字节为单位,返回音频缓冲区的大小。
*另见setBufferSize()函数*
----------
**int QAbstractAudioOutput :: bytesFree ()const [纯虚函数]**
返回音频缓冲区的可用空间(以字节为单位)
----------
**QString QAbstractAudioOutput::category() const [虚函数 virtual]**
音频缓冲区的类别(官方文档没有,这是我个人经验,当然可能有误,望指正)
*另见setCategory()*
----------
**qint64 QAbstractAudioOutput::elapsedUSecs() const [纯虚函数 pure virtual]**
返回调用start()函数之后的毫秒数,包括处于空闲状态的时间和挂起状态的时间。
----------
**QAudio::Error QAbstractAudioOutput::error() const [纯虚函数 pure virtual]**
返回错误状态。
----------
**void QAbstractAudioOutput::errorChanged(QAudio::Error error) [信号 signal]**
当错误状态改变时,该信号被发射。
----------
**QAudioFormat QAbstractAudioOutput :: format ()const [纯虚函数 pure virtual]**
返回正在使用的QAudioFormat()类
*另见setFormat()*
----------
**void QAbstractAudioOutput::notify() [信号 signal]**
当函数setNotifyInterval(x)函数已经调用,即音频数据的时间间隔已经被设置时。该信号被发射。(就是调用setNotifyInterval(x)后,这个信号会被发射。官方文档讲的好详细啊=。=)
----------
**int QAbstractAudioOutput::notifyInterval() const [纯虚函数 pure virtual]**
以毫秒为单位,返回时间间隔
*另见函数setNotifyInterval()*
----------
**int QAbstractAudioOutput::periodSize() const [纯虚函数 pure virtual]**
以字节为单位返回周期大小。
----------
**qint64 QAbstractAudioOutput::processedUSecs() const [纯虚函数 pure virtual]**
返回自调用start()函数后处理的音频数据量(单位为毫秒)
----------
**void QAbstractAudioOutput::reset() [纯虚函数 pure virtual]**
将所有音频数据放入缓冲区,并将缓冲区重置为零。
----------
**void QAbstractAudioOutput::resume() [纯虚函数 pure virtual]**
继续处理暂停后的音频数据 (也就是暂停后继续的意思呗)
----------
**void QAbstractAudioOutput::setBufferSize(int value) [纯虚函数 pure virtual]**
重新设置音频缓冲区的大小(以字节为单位 即输入参数value)
*另见bufferSize()函数*
----------
**void QAbstractAudioOutput::setCategory(const QString &) [虚函数 virtual]**
*参见函数category()*
----------
**void QAbstractAudioOutput::setFormat(const QAudioFormat &fmt) [纯虚函数 pure virtual]**
QAbstractAudioOutput设置QAudioFormat类,只有当QAudio状态为QAudio::StoppedState时,音频格式才会被设置成功。
*另见函数format()*
----------
**void QAbstractAudioOutput::setNotifyInterval(int ms) [纯虚函数 pure virtual]**
设置发送notify()信号的时间间隔。这个ms并不是实时处理的音频数据中的ms数。这个时间间隔是平台相关的。
*另见notifyInterval()*
----------
**void QAbstractAudioOutput::setVolume(qreal volume) [虚函数 virtual]**
设置音量。音量的范围为[0.0 - 1.0]。
*另见函数volume()*
----------
**void QAbstractAudioOutput::start(QIODevice *device) [纯虚函数 pure virtual]**
调用start()函数时,输入参数QIODevice*类型的变量device,用于音频后端处理数据传输。
----------
**QIODevice *QAbstractAudioOutput::start() [纯虚函数 pure virtual]**
返回一个指向正在处理数据传输的QIODevice类型的指针,这个指针是可以被写入的,用于处理音频数据。(参考上边的函数是咋写入的)
----------
**QAudio::State QAbstractAudioOutput::state() const [纯虚函数 pure virtual]**
返回音频处理的状态。
----------
**void QAbstractAudioOutput::stateChanged(QAudio::State state) [信号 signal]**
当音频状态变化的时候,该信号被发射
----------
**void QAbstractAudioOutput::stop() [纯虚函数 pure virtual]**
停止音频输出
----------
**void QAbstractAudioOutput::suspend() [纯虚函数 pure virtual]**
停止处理音频数据,保存处理的音频数据。(就是暂停的意思啊=。=)
----------
**qreal QAbstractAudioOutput::volume() const [虚函数 virtual]**
返回音量。音量范围为[0.0 - 1.0]
*另参阅函数setVolume()*
----------
================================================
FILE: Src/A/QAbstractAxis/QAbstractAxis.md
================================================
[TOC]
# **QAbstractAxis**
----------
## **QAbstractAxis类是用于专门处理坐标轴的类**
| 属性 | 方法|
|------:|:------|
|头文件:|` #include <QAbstractAxis>`|
|实例化:| AbstractAxis|
|继承: |QObject|
|派生:|QBarCategoryAxis, QDateTimeAxis, QLogValueAxis, and QValueAxis|
----------
## **简述**
----------
### **公共类型**
| 类型 | 方法|
|------:|:------|
|enum | AxisType { AxisTypeNoAxis, AxisTypeValue, AxisTypeBarCategory, AxisTypeCategory, AxisTypeDateTime, AxisTypeLogValue }|
|flags | AxisTypes|
----------
### **属性**
| 函数名 | 类型|
|------:|:------|
| alignment :| const Qt::Alignment|
|color : |QColor|
| gridLineColor :| QColor|
| gridLinePen :| QPen|
| gridVisible : |bool|
| labelsAngle : |int|
| labelsBrush : |QBrush|
| labelsColor : |QColor|
| labelsFont : |QFont|
| labelsVisible : |bool|
| linePen : |QPen|
| lineVisible :| bool|
| minorGridLineColor :| QColor|
| minorGridLinePen :| QPen|
| minorGridVisible :| bool|
| orientation : |const Qt::Orientation|
|reverse : |bool|
|shadesBorderColor :| QColor|
|shadesBrush : |QBrush|
| shadesColor : |QColor|
| shadesPen :| QPen|
| shadesVisible : |bool|
| titleBrush : |QBrush|
| titleFont :| QFont|
| titleText :| QString|
| titleVisible : |bool|
| visible : |bool|
----------
### **Public Functions**
| 类型 | 函数名|
|------:|:------|
| |~QAbstractAxis()|
|Qt::Alignment | alignment() const|
|QColor | gridLineColor()|
|QPen | gridLinePen() const|
|void | hide()|
|bool | isGridLineVisible() const|
|bool | isLineVisible() const|
|bool | isMinorGridLineVisible() const|
|bool | isReverse() const|
|bool | isTitleVisible() const|
|bool | isVisible() const|
|int | labelsAngle() const|
|QBrush | labelsBrush() const|
|QColor | labelsColor() const|
|QFont | labelsFont() const|
|bool | labelsVisible() const|
|QPen | linePen() const|
|QColor | linePenColor() const|
|QColor | minorGridLineColor()|
|QPen | minorGridLinePen() const|
|Qt::Orientation | orientation() const|
|void |setGridLineColor(const QColor &color)|
|void | setGridLinePen(const QPen &pen)|
|void | setGridLineVisible(bool visible = true)|
|void |setLabelsAngle(int angle)|
|void | setLabelsBrush(const QBrush &brush)|
|void | setLabelsColor(QColor color)|
|void | setLabelsFont(const QFont &font)|
|void | setLabelsVisible(bool visible = true)|
|void | setLinePen(const QPen &pen)|
|void | setLinePenColor(QColor color)|
|void |setLineVisible(bool visible = true)|
|void | setMax(const QVariant &max)|
|void | setMin(const QVariant &min)|
|void | setMinorGridLineColor(const QColor &color)|
|void| setMinorGridLinePen(const QPen &pen)|
|void | setMinorGridLineVisible(bool visible = true)|
|void | setRange(const QVariant &min, const QVariant &max)|
|void | setReverse(bool reverse = true)|
|void | setShadesBorderColor(QColor color)|
|void | setShadesBrush(const QBrush &brush)|
|void | setShadesColor(QColor color)|
|void | setShadesPen(const QPen &pen)|
|void | setShadesVisible(bool visible = true)|
|void | setTitleBrush(const QBrush &brush)|
|void | setTitleFont(const QFont &font)|
|void | setTitleText(const QString &title)|
|void | setTitleVisible(bool visible = true)|
|void | setVisible(bool visible = true)|
|QColor | shadesBorderColor() const|
|QBrush | shadesBrush() const|
|QColor | shadesColor() const|
|QPen | shadesPen() const|
|bool | shadesVisible() const|
|void | show()|
|QBrush | titleBrush() const|
|QFont | titleFont() const|
|QString | titleText() const|
|virtual AxisType | type() const = 0|
----------
### **信号**
| 类型 | 函数名|
|------:|:------|
|void | colorChanged(QColor color)|
|void | gridLineColorChanged(const QColor &color)|
|void | gridLinePenChanged(const QPen &pen)|
|void | gridVisibleChanged(bool visible)|
|void | labelsAngleChanged(int angle)|
|void | labelsBrushChanged(const QBrush &brush)|
|void | labelsColorChanged(QColor color)|
|void | labelsFontChanged(const QFont &font)|
|void | labelsVisibleChanged(bool visible)|
|void | linePenChanged(const QPen &pen)|
|void | lineVisibleChanged(bool visible)|
|void | minorGridLineColorChanged(const QColor &color)|
|void | minorGridLinePenChanged(const QPen &pen)|
|void | minorGridVisibleChanged(bool visible)|
|void | reverseChanged(bool reverse)|
|void | shadesBorderColorChanged(QColor color)|
|void | shadesBrushChanged(const QBrush &brush)|
|void | shadesColorChanged(QColor color)|
|void | shadesPenChanged(const QPen &pen)|
|void | shadesVisibleChanged(bool visible)|
|void | titleBrushChanged(const QBrush &brush)|
|void | titleFontChanged(const QFont &font)|
|void | titleTextChanged(const QString &text)|
|void | titleVisibleChanged(bool visible)|
|void | visibleChanged(bool visible)|
----------
## **详细说明**
----------
QAbstractAxis是专门用于处理坐标轴的基类。
每一个连续的序列可以绑定到一个或者多个水平轴和垂直轴,但是不同域的混合轴的类型是不支持的。比如在同一个方向指定QValueAxis和QLogValueAxis。
每个轴的元素(比如轴线,标题,标签,网格线,阴影,可见性)都是可以控制的。
----------
## **成员变量**
**enum QAbstractAxis::AxisType**
**flags QAbstractAxis::AxisTypes**
----------
***这个枚举类型指定了轴对象的类型***
| 变量 | 值|
|------:|:------|
|QAbstractAxis::AxisTypeNoAxis| 0x0|
|QAbstractAxis::AxisTypeValue| 0x1|
|QAbstractAxis::AxisTypeBarCategory| 0x2|
|QAbstractAxis::AxisTypeCategory| 0x4|
|QAbstractAxis::AxisTypeDateTime| 0x8|
|QAbstractAxis::AxisTypeLogValue| 0x10|
`AxisTypes`是`QFlags<AxisType>`的typedef。它是AxisType类型的组合。
(也就是个宏呗)
----------
**alignment : const Qt::Alignment**
该属性是轴的对齐属性
其值可以为 Qt::AlignLeft, Qt::AlignRight, Qt::AlignBottom, or Qt::AlignTop.
**相关函数**
| 类型 | 函数名|
|------:|:------|
|Qt::Alignment | alignment() const|
----------
**color : QColor**
该属性是指坐标轴与刻度的颜色
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QColor | linePenColor() const|
|void |setLinePenColor(QColor color)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void | colorChanged(QColor color)|
----------
**gridLineColor : QColor**
该属性是指网格线的颜色
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QColor |gridLineColor()|
|void| setGridLineColor(const QColor &color)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| gridLineColorChanged(const QColor &color)|
----------
**gridLinePen : QPen**
该属性是指绘制网格线的笔
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QPen| gridLinePen() const|
|void| setGridLinePen(const QPen &pen)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| gridLinePenChanged(const QPen &pen)|
----------
**gridVisible : bool**
该属性是网格线是否可见
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QPen| gridLinePen() const|
|void| setGridLinePen(const QPen &pen)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| gridLinePenChanged(const QPen &pen)|
----------
**labelsAngle : int**
该属性以度数保存轴坐标的角度
**相关函数**
| 类型 | 函数名|
|------:|:------|
|int| labelsAngle() const|
|void| setLabelsAngle(int angle)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| labelsAngleChanged(int angle)|
----------
**labelsBrush : QBrush**
该属性表示用于绘制标签的画笔
只有画刷的颜色是相关的(这句话其实我不太理解Only the color of the brush is relevant.)
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QBrush | labelsBrush() const|
|void |setLabelsBrush(const QBrush &brush)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void | labelsBrushChanged(const QBrush &brush)|
----------
**labelsColor : QColor**
该属性表示轴标签的颜色
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QColor| labelsColor() const|
|void| setLabelsColor(QColor color)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| labelsColorChanged(QColor color)|
----------
**labelsFont : QFont**
该属性表示轴标签的字体信息
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QFont| labelsFont() const|
|void| setLabelsFont(const QFont &font)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| labelsFontChanged(const QFont &font)|
----------
**labelsVisible : bool**
该属性表示轴标签是否可见
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| labelsVisible() const|
|void| setLabelsVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| labelsVisibleChanged(bool visible)|
----------
**linePen : QPen**
该属性表示绘制轴线的笔相关
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QPen| linePen() const|
|void| setLinePen(const QPen &pen)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| linePenChanged(const QPen &pen)|
----------
**lineVisible : bool**
该属性表示轴线是否可见
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool |isLineVisible() const|
|void| setLineVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| lineVisibleChanged(bool visible)|
----------
**minorGridLineColor : QColor**
该属性表示副格线的颜色
仅适用于支持副网格线的轴
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QColor | minorGridLineColor()|
|void |setMinorGridLineColor(const QColor &color)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| minorGridLineColorChanged(const QColor &color)|
----------
**minorGridLinePen : QPen**
该属性表示副格线的笔
仅适用于支持副网格线的轴
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QPen| minorGridLinePen() const|
|void| setMinorGridLinePen(const QPen &pen)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| minorGridLinePenChanged(const QPen &pen)|
----------
**minorGridVisible : bool**
该属性表示副格线是否可见
仅适用于支持副网格线的轴
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| isMinorGridLineVisible() const|
|void| setMinorGridLineVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void |minorGridVisibleChanged(bool visible)|
----------
**orientation : const Qt::Orientation**
该属性表示坐标轴的方向。
当坐标轴被添加到图表时,该属性为Qt::Horizontal或者Qt::Vertical
**相关函数**
| 类型 | 函数名|
|------:|:------|
|Qt::Orientation| orientation() const|
----------
**reverse : bool**
该属性表示是否使用反转轴。
该值默认为false。
反转轴由直线,样条,散列图系列以及笛卡尔图表组成的区域支持。如果一个方向相反,或者行为为定义,则所有相同方向的所有轴必须保持一致。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| isReverse() const|
|void| setReverse(bool reverse = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| reverseChanged(bool reverse)|
----------
**shadesBorderColor : QColor**
该属性表示坐标轴阴影的边框(笔)颜色
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QColor| shadesBorderColor() const|
|void| setShadesBorderColor(QColor color)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| shadesBorderColorChanged(QColor color)|
----------
**shadesBrush : QBrush**
该属性表示用于绘制轴阴影的画笔(网格线之间的区域)
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QPen| shadesPen() const|
|void| setShadesPen(const QPen &pen)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| shadesPenChanged(const QPen &pen)|
----------
**shadesVisible : bool**
该属性表示轴阴影是否可见
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| shadesVisible() const|
|void| setShadesVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| shadesVisibleChanged(bool visible)|
----------
**titleBrush : QBrush**
该属性表示用于绘制坐标轴标题文本的画笔。
只影响画刷的颜色。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QBrush| titleBrush() const|
|void| setTitleBrush(const QBrush &brush)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| titleBrushChanged(const QBrush &brush)|
----------
**titleFont : QFont**
该属性表示坐标轴标题的字体。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QFont| titleFont() const|
|void| setTitleFont(const QFont &font)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| titleFontChanged(const QFont &font)|
----------
**titleText : QString**
该属性表示坐标轴的标题
默认为空,坐标轴的标题支持HTML的格式。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|QString| titleText() const|
|void| setTitleText(const QString &title)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| titleTextChanged(const QString &text)|
----------
**titleVisible : bool**
该属性表示坐标轴的可见性。
默认值为true。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| isTitleVisible() const|
|void| setTitleVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| titleVisibleChanged(bool visible)|
----------
**visible : bool**
该属性表示坐标轴的可见性。
**相关函数**
| 类型 | 函数名|
|------:|:------|
|bool| isVisible() const|
|void| setVisible(bool visible = true)|
**通知信号**
| 类型 | 函数名|
|------:|:------|
|void| visibleChanged(bool visible)|
----------
##**成员函数**
----------
**QAbstractAxis::~QAbstractAxis()**
析构函数,销毁轴对象,当一个坐标轴添加到图表时,该图表获得该坐标轴的所有权。
----------
**void QAbstractAxis::colorChanged(QColor color) [信号]**
当坐标轴的颜色变化时,该信号被发射。
注意:属性color的通知信号。
----------
**void QAbstractAxis::gridLineColorChanged(const QColor &color) [信号]**
当绘制网格线的笔的颜色改变时,该信号被发射。
注意:属性gridLineColor的通知信号。
----------
**QPen QAbstractAxis::gridLinePen() const**
返回用于绘制网格的笔。
注意:属性gridLinePen的Getter函数。
另参见函数setGridLinePen()。
----------
**void QAbstractAxis :: gridLinePenChanged(const QPen&pen) [信号]**
当用于绘制网格线的笔变化时,会发出此信号。
注意:属性gridLinePen的通知信号。
----------
**void QAbstractAxis::gridVisibleChanged(bool visible) [信号]**
当坐标轴的网格线的可见性变化时,发出该信号。
注意:属性gridVisible的通知信号。
----------
**void QAbstractAxis::hide()**
使坐标轴,阴影,标签,网格线不可见。
----------
**void QAbstractAxis::labelsAngleChanged(int angle) [信号]**
当坐标轴标签的角度变化时,发出该信号。
注意:属性标签角度的通知信号
----------
**QBrush QAbstractAxis::labelsBrush() const**
返回用于绘制标签的画笔。
注意:属性labelsBrush的Getter函数。
另参见setLabelsBrush().
----------
**void QAbstractAxis::labelsBrushChanged(const QBrush &brush) [信号]**
当用于绘制坐标轴标签的画笔改变时,会发出此信号。
属性Brush的通知信号。
----------
**void QAbstractAxis :: labelsColorChanged(QColor color) [信号signal]**
当坐标轴标签的颜色改变时,会发出此信号。
属性labelsColor的通知信号。
----------
**QFont QAbstractAxis::labelsFont()const **
返回用于绘制标签的字体。
注意:属性labelsFont的Getter函数。
另参见函数setLabelsFont()。
----------
**void QAbstractAxis :: labelsFontChanged(const QFont&font)[信号]**
当坐标轴的字体改变时,会发出此信号。
属性labelsFont的通知信号。
----------
**void QAbstractAxis::labelsVisibleChanged(bool visible) [信号]**
当坐标轴标签的可见性变化时,会发出此信号。
属性labelsVisible的通知信号。
----------
**QPen QAbstractAxis::linePen() const**
返回用于绘制轴线与刻度线的笔。
注意:属性linePen的Getter函数。
另参阅函数setLinePen()。
----------
**void QAbstractAxis::linePenChanged(const QPen &pen) [信号]**
当绘制坐标轴的笔变化时,会发出此信号。
注意:属性linePen的通知信号。
----------
**void QAbstractAxis::lineVisibleChanged(bool visible) [信号]**
当坐标轴线的可见性变化时,会发出此信号。
注意:属性lineVisible的通知信号。
----------
**void QAbstractAxis::minorGridLineColorChanged(const QColor &color) [信号]**
当绘制副格线的笔的颜色变化时,该信号被发射。
注意:属性minorGridLineColor的通知信号。
----------
**void QAbstractAxis::minorGridLinePenChanged(const QPen &pen) [信号]**
当绘制副格线的笔变化时,该信号被发射。
注意:属性minorGridLinePen的通知信号。
----------
**void QAbstractAxis::minorGridVisibleChanged(bool visible) [信号]**
当绘制副格线的可见性变化时,该信号被发射。
注意:属性minorGridVisible的通知信号。
----------
**Qt::Orientation QAbstractAxis::orientation() const**
返回坐标轴的方向(垂直或者水平)
注意:坐标轴方向的Getter函数。
----------
**void QAbstractAxis::setGridLinePen(const QPen &pen)**
设置绘制网格线的笔。
注意:gridLinePen的Setter函数。
另参见函数gridLinePen()。
----------
**void QAbstractAxis::setLabelsBrush(const QBrush &brush)**
设置用于绘制标签的画笔。
注意:属性LabelsBrush的Setter函数。
另参阅labelsBrush().
----------
**void QAbstractAxis::setLabelsFont(const QFont &font)**
设置用于绘制标签的字体相关
注意:属性labelsFont的Setter函数。
另参阅函数labelsFont()。
----------
**void QAbstractAxis::setLinePen(const QPen &pen)**
设置用于绘制坐标轴线和刻度线的笔。
注意:属性linePen的Setter函数。
另参见函数linePen()。
----------
**void QAbstractAxis::setLineVisible(bool visible = true)**
设置坐标轴线与刻度线是否可见。
注意:属性lineVisible的Setter函数
另参见函数isLineVisible()。
----------
**void QAbstractAxis::setMax(const QVariant &max)**
设置坐标轴上显示的最大值。根据当前坐标轴的类型,最大值参数会被转换为适当的值。如果转化失败,该函数设置无效。
----------
**void QAbstractAxis::setMin(const QVariant &min)**
设置坐标轴上显示的最小值。根据当前坐标轴的类型,最小值参数会被转换为适当的值。如果转化失败,该函数设置无效。
----------
**void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)**
设置坐标轴的范围。根据当前坐标轴的类型,最大值最小值会被转换为适当的值。如果转化失败,该函数设置无效。
----------
**void QAbstractAxis::setShadesBrush(const QBrush &brush)**
设置用于绘制阴影的画笔。
注意:属性shadesBrush的Setter函数。
另参见函数shadesBrush().
----------
**void QAbstractAxis::setShadesPen(const QPen &pen)**
设置用于绘制阴影的笔。
注意:属性shadesPen的Setter函数。
另参见函数shadesPen().
----------
**void QAbstractAxis::setTitleBrush(const QBrush &brush)**
设置用于绘制标题的画笔。
注意:属性titleBrush的Setter函数。
另参见函数titleBrush().
----------
**void QAbstractAxis::setTitleFont(const QFont &font)**
设置用于绘制标题的笔。
注意:属性titleFont的Setter函数。
另参见函数titleFont().
----------
**void QAbstractAxis::setVisible(bool visible = true)**
设置坐标轴,阴影,标签,网格线是否可见。
注意:属性visible的Setter函数。
另参见函数isVisible().
----------
**void QAbstractAxis::shadesBorderColorChanged(QColor color) [信号signal]**
当绘制坐标轴边框的颜色变化时,会发出此信号。
注意:属性shadesBorderColor的通知信号。
----------
**QBrush QAbstractAxis::shadesBrush() const**
返回用于绘制阴影的画笔。
注意:属性shadesBrush()的Getter函数。
另参阅函数setShadesBrush().
----------
**void QAbstractAxis::shadesBrushChanged(const QBrush &brush) [信号signal]**
当绘制坐标轴阴影的画刷变化时,会发出此信号。
注意:属性shadesBrush()的通知信号。
----------
**void QAbstractAxis::shadesColorChanged(QColor color) [信号signal]**
当绘制坐标轴阴影颜色发生变化时,会发出此信号。
注意:属性shadesColor()的通知信号。
----------
**QPen QAbstractAxis::shadesPen() const**
返回用于绘制阴影的笔。
注意:属性shadesPen()的Getter函数
另参阅函数setShadesPen().
----------
**void QAbstractAxis::shadesPenChanged(const QPen &pen) [信号signal]**
当绘制坐标轴阴影的笔发生变化时,会发出此信号。
注意:属性shadesPen()的通知信号。
----------
**void QAbstractAxis::shadesVisibleChanged(bool visible) [信号signal]**
当坐标轴的阴影可见性变化时,会发出此信号。
注意:属性shadesVisible()的通知信号。
----------
**void QAbstractAxis::show()**
使坐标轴,阴影,标签,网格线可见。
----------
**QBrush QAbstractAxis::titleBrush() const**
返回用于绘制标题的画刷
注意:属性titleBrush的Getter函数
另参阅函数setTitleBrush()
----------
**void QAbstractAxis::titleBrushChanged(const QBrush &brush) [信号signal]**
当绘制坐标轴标题的画刷变化时,该信号被发射
注意:titleBrush的通知信号。
----------
**QFont QAbstractAxis::titleFont() const**
返回绘制标题的笔相关属性。
注意:titleFont的Getter函数
另参阅函数setTitleFont()
----------
**void QAbstractAxis::titleFontChanged(const QFont &font) [信号 signal]**
当坐标轴标题的字体属性更改时,会发出此信号。
注意:titleFont的通知信号。
----------
**void QAbstractAxis::titleTextChanged(const QString &text) [信号 signal]**
当坐标轴标题的文本内容改变时,会发出此信号。
注意:titleText的通知信号。
----------
**void QAbstractAxis::titleVisibleChanged(bool visible) [信号 signal]**
当坐标轴的标题文本的可见性变化时,会发出此信号。
注意:titleVisible的通知信号
----------
**AxisType QAbstractAxis::type() const**
返回坐标轴的类型
----------
**void QAbstractAxis::visibleChanged(bool visible)**
当坐标轴的可见性变化时,会发出此信号。
注意:坐标轴的visible的通知信号
================================================
FILE: Src/A/QAbstractBarSeries/QAbstractBarSeries.md
================================================
[TOC]
# **QAbstractBarSeries**
----------
## **QAbstractBarSeries是所有柱状图/条形图系列的基类**
| 属性 | 方法|
|------:|:------|
|头文件:|`#include<QAbstractBarSeries>`|
|实例化:|AbstractBarSeries|
|继承: |QAbstractSeries|
|派生:|QBarSeries, QHorizontalBarSeries, QHorizontalPercentBarSeries, QHorizontalStackedBarSeries, QPercentBarSeries, and QStackedBarSeries|
----------
## **简述**
----------
### **公共类型**
| 类型 | 方法|
|------:|:------|
|enum | LabelsPosition { LabelsCenter, LabelsInsideEnd, LabelsInsideBase, LabelsOutsideEnd }|
----------
### **属性**
| 函数名 | 类型|
|------:|:------|
| barWidth :| qreal|
|count : |const int|
| labelsAngle :| qreal|
5个属性继承自QAbstractSeries
1个属性继承自QObject
----------
### **Public Functions**
| 类型 | 函数名|
|------:|:------|
|virtual | ~QAbstractBarSeries()|
|bool | append(QBarSet *set)|
|bool | append(QList<QBarSet *> sets)|
|QList<QBarSet *>| barSets() const|
|qreal | barWidth() const|
|void | clear()|
|int | count() const|
|bool | insert(int index, QBarSet *set)|
|bool | isLabelsVisible() const|
|qreal |labelsAngle() const|
|QString | labelsFormat() const|
|QAbstractBarSeries::LabelsPosition | labelsPosition() const|
|bool | remove(QBarSet *set)|
|void | setBarWidth(qreal width)|
|void | setLabelsAngle(qreal angle)|
|void | setLabelsFormat(const QString &format)|
|void| setLabelsPosition(QAbstractBarSeries::LabelsPosition position)|
|void |setLabelsVisible(bool visible = true)|
|bool | take(QBarSet *set)|
15个公共函数继承自QAbstractSeries
32个公共函数继承自QObject
----------
### **信号**
| 类型 | 函数名|
|------:|:------|
|void |barsetsAdded(QList<QBarSet *> sets)|
|void |barsetsRemoved(QList<QBarSet *> sets)|
|void | clicked(int index, QBarSet *barset)|
|void | countChanged()|
|void | doubleClicked(int index, QBarSet *barset)|
|void | hovered(bool status, int index, QBarSet *barset)|
|void | labelsAngleChanged(qreal angle)|
|void | labelsFormatChanged(const QString &format)|
|void | labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)|
|void | labelsVisibleChanged()|
|void | pressed(int index, QBarSet *barset)|
|void | released(int index, QBarSet *barset)|
----------
### **额外继承的**
1个公共槽继承自QObject
11个静态成员函数继承自QObject
9个保护函数继承自QObject
----------
## **详细说明**
QAbstractBarSeries类是所有条形柱的抽象类。
在条形图中,条形柱被定义为包含一种数据的集合。条形柱的位置由其类别与数值来决定。条形柱组合则是属于同一类别的条形柱。条形柱的显示则是由创建图表的时候决定的。
如果使用QValueAxis来代替QBarCategoryAxis当做图表的主轴。那么条形柱别按照索引值来分类。
可以参考Qt Example(example 这里我还没有来得及翻译)
----------
## 成员类型
enum QAbstractBarSeries::LabelsPosition**
这个枚举值表示的是条形柱标签的位置:
| 枚举值 | 数值 | 描述 |
|------:|:------|:------|
| QAbstractBarSeries::LabelsCenter| 0 | 中部 |
| QAbstractBarSeries::LabelsInsideEnd | 1 | 顶部 |
| QAbstractBarSeries::LabelsInsideBase | 2 | 底部 |
| QAbstractBarSeries::LabelsOutsideEnd | 3 | 外部 |
================================================
FILE: Src/A/QAbstractItemModel/QAbstractItemModel.md
================================================
# QAbstractItemModel 类
QAbstractItemModel类为项模型类提供了抽象接口。[更多...]()
| 属性 | 方法 |
| ---- | ---- |
| 头文件 | `#include <QAbstractItemModel> ` |
| qmake | `QT += core` |
| 继承 | [QObject]() |
| 派生 | [QAbstractListModel]()、[QAbstractProxyModel]()、[QAbstractTableModel]()、[QConcatenateTablesProxyModel]()、[QDirModel]()、[QFileSystemModel]() 和 [QStandardItemModel]() |
## 公共成员类型
| 类型 | 类型名称 |
| ---- | ---- |
| enum class | [CheckIndexOption](#checkindexoption-checkindexoptions) { NoOption, IndexIsValid, DoNotUseParent, ParentIsInvalid } |
| flags | [CheckIndexOptions](#checkindexoption-checkindexoptions) |
| enum | [LayoutChangeHint](#layoutchangehint) { NoLayoutChangeHint, VerticalSortHint, HorizontalSortHint } |
## 公共成员函数
| 类型 | 函数名称 |
| ---- | ---- |
| | [QAbstractItemModel](#qabstractitemmodel)(QObject *parent = nullptr) |
| virtual | ~[QAbstractItemModel](#~qabstractitemmodel)() |
| virtual QModelIndex | [buddy](#buddy)(const QModelIndex &index) const |
| virtual bool | [canDropMimeData](#candropmimedata)(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const s|
| virtual bool | [canFetchMore](#canfetchmore)(const QModelIndex &parent) const |
| bool | [checkIndex](#checkindex)(const QModelIndex &index, QAbstractItemModel::CheckIndexOptions options = CheckIndexOption::NoOption) const |
| virtual int | [columnCount](#columncount)(const QModelIndex &parent = QModelIndex()) const = 0 |
| virtual QVariant | [data](#data)(const QModelIndex &index, int role = Qt::DisplayRole) const = 0 |
| virtual bool | [dropMimeData](#dropMimeData)(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| virtual void | [fetchMore](#fetchMore)(const QModelIndex &parent) |
| virtual Qt::ItemFlags | [flags](#flags)(const QModelIndex &index) const |
| virtual bool | [hasChildren](#haschildren) QModelIndex &parent = QModelIndex()) const |
| bool | [hasIndex](#hasindex) row, int column, const QModelIndex &parent = QModelIndex()) const |
| virtual QVariant | [headerData](#headerdata) section, Qt::Orientation orientation, int role = Qt::DisplayRole) const |
| virtual QModelIndex | [index](#index) row, int column, const QModelIndex &parent = QModelIndex()) const = 0 |
| bool | [insertColumn](#insertcolumn) column, const QModelIndex &parent = QModelIndex()) |
| virtual bool | [insertColumns](#insertcolumns) column, int count, const QModelIndex &parent = QModelIndex()) |
| bool | [insertRow](#insertRow)(int row, const QModelIndex &parent = QModelIndex()) |
| virtual bool | [insertRows](#insertrows) row, int count, const QModelIndex &parent = QModelIndex()) |
| virtual QMap<int, QVariant> | [itemData](#itemdata) QModelIndex &index) const |
| virtual QModelIndexList | [match](#match) QModelIndex &start, int role, const QVariant &value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags (Qt::MatchStartsWith|Qt::MatchWrap)) const |
| virtual QMimeData * | [mimeData](#mimedata) QModelIndexList &indexes) const |
| virtual QStringList | [mimeTypes](#mimetypes) const |
| bool | [moveColumn](#movecolumn) QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild) |
| virtual bool | [moveColumns](#movecolumns) QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) |
| bool | [moveRow](#moverow) QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild) |
| virtual bool | [moveRows](#moverows) QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) |
| virtual QModelIndex | [parent](#parent) QModelIndex &index) const = 0 |
| bool | [removeColumn](#removecolumn) column, const QModelIndex &parent = QModelIndex()) |
| virtual bool | [removeColumns](#removecolumns) column, int count, const QModelIndex &parent = QModelIndex()) |
| bool | [removeRow](#removerow) row, const QModelIndex &parent = QModelIndex()) |
| virtual bool | [removeRows](#removerows) row, int count, const QModelIndex &parent = QModelIndex()) |
| virtual QHash<int, QByteArray> | [roleNames](#rolenames) const |
| virtual int | [rowCount](#rowcount) QModelIndex &parent = QModelIndex()) const = 0 |
| virtual bool | [setData](#setdata) QModelIndex &index, const QVariant &value, int role = Qt::EditRole) |
| virtual bool | [setHeaderData](#setheaderdata) section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) |
| virtual bool | [setItemData](#setitemdata) QModelIndex &index, const QMap<int, QVariant> &roles) |
| virtual QModelIndex | [sibling](#sibling) row, int column, const QModelIndex &index) const |
| virtual void | [sort](#sort) column, Qt::SortOrder order = Qt::AscendingOrder) |
| virtual QSize | [span](#span) QModelIndex &index) const |
| virtual Qt::DropActions | [supportedDragActions](#supporteddragactions) const |
| virtual Qt::DropActions | [supportedDropActions](#supporteddropactions) const |
## 公共槽函数
| 类型 | 函数名称 |
| ---- | ---- |
| virtual void | [revert](#revert)() |
| virtual bool | [submit](#submit)() |
## 信号
| 类型 | 函数名称 |
| ---- | ---- |
| void | [columnsAboutToBeInserted](#columnsabouttobeinserted) QModelIndex &parent, int first, int last) |
| void | [columnsAboutToBeMoved](#columnsabouttobemoved)(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
| void | [columnsAboutToBeRemoved](#columnsabouttoberemoved)(const QModelIndex &parent, int first, int last) |
| void | [columnsInserted](#columnsinserted)(QModelIndex &parent, int first, int last) |
| void | [columnsMoved](#columnsmoved)(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column) |
| void | [columnsRemoved](#columnsremoved)(const QModelIndex &parent, int first, int last) |
| void | [dataChanged](#datachanged)(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) |
| void | [headerDataChanged](#headerdatachanged)(Qt::Orientation orientation, int first, int last) |
| void |[layoutAboutToBeChanged](#layoutabouttobechanged)(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint) |
| void | [layoutChanged](#layoutchanged)(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint) |
| void | [modelAboutToBeReset](#modelabouttobereset)() |
| void | [modelReset](#modelreset)() |
| void | [rowsAboutToBeInserted](#rowsabouttobeinserted)(const QModelIndex &parent, int start, int end) |
| void | [rowsAboutToBeMoved](#rowsabouttobemoved)(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
| void | [rowsAboutToBeRemoved](#rowsabouttoberemoved)(const QModelIndex &parent, int first, int last) |
| void | [rowsInserted](#rowsinserted)(const QModelIndex &parent, int first, int last) |
| void | [rowsMoved](#rowsmoved)(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row) |
| void | [rowsRemoved](#rowsremoved)(const QModelIndex &parent, int first, int last) |
## 受保护的函数
| 类型 | 函数名称 |
| ---- | ---- |
| void | [beginInsertColumns](#begininsertcolumns)(const QModelIndex &parent, int first, int last) |
| void | [beginInsertRows](#begininsertrows)(const QModelIndex &parent, int first, int last) |
| bool | [beginMoveColumns](#beginmovecolumns)(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
| bool | [beginMoveRows](#beginmoverows)(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild) |
| void | [beginRemoveColumns](#beginremovecolumns)(const QModelIndex &parent, int first, int last) |
| void | [beginRemoveRows](#beginremoverows)(const QModelIndex &parent, int first, int last) |
| void | [beginResetModel](#beginresetmodel)() |
| void | [changePersistentIndex](#changepersistentindex)(const QModelIndex &from, const QModelIndex &to) |
| void | [changePersistentIndexList](#changepersistentindexlist)(const QModelIndexList &from, const QModelIndexList &to) |
| QModelIndex | [createIndex](#createindex)(int row, int column, void *ptr = nullptr) const |
| QModelIndex | [createIndex](#createindex)(int row, int column, quintptr id) const |
| void | [endInsertColumns](#begininsertcolumns)() |
| void | [endInsertRows](#endinsertrows)() |
| void | [endMoveColumns](#endmovecolumns)() |
| void | [endMoveRows](#endmoverows)() |
| void | [endRemoveColumns](#endremovecolumns)() |
| void | [endRemoveRows](#endremoverows)() |
| void | [endResetModel](#endresetmodel)() |
| QModelIndexList | [persistentIndexList](#changepersistentindexlist)() const |
## 受保护的槽函数
| 类型 | 函数名称 |
| ---- | ---- |
| void | [resetInternalData](#resetinternaldata)() |
## 详细描述
`QAbstractItemModel` 类定义了项模型与模型/视图体系结构中的其他组件进行交互操作时必须使用的标准接口。应该子类化该类创建新的模型,而不是直接实例化使用。
`QAbstractItemModel` 类是[模型/视图类]()中的一个,也是 `Qt` [模型/视图框架]()的一部分。它可以用作 `QML` 中的项视图元素或 `Qt Widgets` 模块中的项视图类的底层数据模型。
如果需要一个模型来使用项视图,比如 `QML` 的 `List View` 元素或者 `C++ widgets` 的 [QListView]() 或者 [ QTableView](),应该考虑子类化 [QAbstractListModel]() 或者 [QAbstractTableModel]() 而不是使用该类。
底层数据模型作为表的层次结构暴露给视图和委托。如果不使用层次结构,那么模型就是一个简单的具有行和列的表。每个项都有一个由 [QModelIndex]() 指定的惟一索引。

每个数据项都可以通过包含一个关联的模型索引的模型进行访问。该索引可以通过 [index()]() 函数获得。每个索引可能有一个 [sibling()]() 索引;子项有一个 [parent()]() 索引。
每个项目都有许多与之关联的数据元素,可以通过为模型的 [data()]() 函数指定一个角色(请参阅 [Qt::ItemDataRole]())来检索它们。可以使用 [itemData()]() 函数同时获取所有可用角色的数据。
使用特定的 [Qt::ItemDataRole]() 设置每个角色的数据。可以使用 [setData()]() 单独设置各个角色的数据,也可以使用 [setItemData]() 设置所有角色的数据。
可以使用 [flags()]() 查询项(请参阅 [Qt::ItemFlag]()),以查看是否可以通过其他方式选择,拖动或操纵它们。
如果项具有子对象,则 [hasChildren]() 为相应的索引返回 `true`。
该模型在层次结构的每个级别都有一个 [rowCount()]() 和 [columnCount]()。可以使用 [insertRows()](),[insertColumns()](),[removeRows()]() 和 [removeColumns()]() 插入和删除行和列。
模型发出信号以指示变化。例如,只要模型可用的数据项发生更改,就会发出 [dataChanged()]()。对模型提供的标题的更改将将发射 [headerDataChanged()]() 信号。如果底层数据的结构发生了变化,则模型可以发出 [layoutChanged()]() 来向任何附加的视图指示它们应该重新显示所显示的任何项,并需要考虑到新的结构。
可以使用 [match()]() 函数在模型中搜索可用的项以查找特定数据。
要对模型进行排序,可以使用 [sort()]()。
### 子类化
**注意:** 在[模型子类化参考]()中有一些关于模型子类化的通用指南。
子类化 [QAbstractItemModel]() 时,至少必须实现 [index()](),[parent()](),[rowCount()](),[columnCount()]() 和 [data()]()。这些函数在所有的只读模型中使用,同样也构成了可编辑模型的基础。
还可以为模型重新实现 [hasChildren()]() 来提供特殊的行为,而不是重新实现成本很高的 [rowCount()]()。这使得模型可以限制视图请求的数据量,并且可以作为实现模型数据的惰性填充的一种方式。
要在模型中启用编辑,还必须实现 [setData]() 和重新实现 [flags()]() 以确保返回 `ItemIsEditable`。还可以重新实现 [headerData()]() 和 [setHeaderData]() 来控制呈现模型标题的方式。
当分别重新实现 [setData()]() 和 [setHeaderData()]() 函数时,必须显式发射 [dataChanged()]() 和 [headerDataChanged()]() 信号。
定制模型需要创建模型索引以供其他组件使用。为此,请使用适当的行号和列号以及相应的标识符调用 [createIndex()](),并将其作为指针或整数值。这些值的组合对于每个项都必须是唯一的。定制模型通常在其他重新实现的函数中使用这些唯一标识符,以检索项数据并访问有关该项的父项和子项的信息。有关唯一标识符的更多信息,请参见[简单树模型]()示例。
不必支持 [Qt::ItemDataRole]() 中定义的每个角色。根据模型中包含的数据类型,可能只有实现 [data()]() 函数以返回一些更常见角色的有效信息才有用。大多数模型至少为 [Qt::DisplayRole]() 提供项数据的文本表示,行为良好的模型也应为 [Qt::ToolTipRole]() 和 [Qt::WhatsThisRole]() 提供有效信息。支持这些角色可使模型与标准 `Qt` 视图一起使用。但是,对于某些处理高度专业化数据的模型,仅为用户定义的角色提供数据可能是合适的。
提供可调整数据结构大小的接口的模型可以提供 [insertRows()](),[removeRows()](),[insertColumns()]() 和 [removeColumns()]() 的实现。在实现这些函数时,重要的是要在模型尺寸大小发生 *之前* 和 *之后* 将有关模型尺寸的更改通知所有连接的视图:
- [insertRows()]() 的实现必须在将新行插入数据结构 *之前* 调用 [beginInsertRows()](),*然后立即* 调用 [endInsertRows()]()。
- [insertColumns()]() 的实现必须在将新列插入数据结构 *之前* 调用 [beginInsertColumns()](),*然后立即* 调用 [endInsertColumns()]()。
- [removeRows()]() 的实现必须在从数据结构中删除行 *之前* 调用 [beginRemoveRows()](),*然后立即* 调用 [endRemoveRows()]()。
- [removeColumns()]() 的实现必须在列从数据结构中删除之前调用 [beginRemoveColumns()](),*然后立即* 调用 [endRemoveColumns()]()。
这些函数发出的私有信号使附加组件有机会在任何数据变得不可用之前采取行动。使用这些 `begin` 和 `end` 函数封装插入和删除操作还使模型能够正确地管理[持久模型索引]()。**如果希望正确处理选择,则必须确保调用了这些函数。** 如果插入或移除带有子项的项,则不需要为子项调用这些函数。换句话说,父项将管理其子项。
要创建增量填充的模型,可以重新实现 [fetchMore()]() 和 [canFetchMore()]()。如果 [fetchMore()]() 的重新实现向模型中添加了行,则必须调用 [beginInsertRows()]() 和 [endInsertRows()]()。
参见[模型类]()、[模型子类化参考]()、[QModelIndex]()、[QAbstractItemView]()、[在项视图中使用拖放](../../M/Model_View_Programming/Model_View_Programming.md#在项视图中使用拖放)、[简单DOM模型示例]()、[简单树模型示例]()、[可编辑树模型示例]()和 [Fetch More示例]()。
## 成员类型文档
### CheckIndexOption CheckIndexOptions
**enum class QAbstractItemModel::CheckIndexOption**
**flags QAbstractItemModel::CheckIndexOptions**
这个枚举可以用来控制 [QAbstractItemModel::checkIndex()]() 执行的检查。
| 常量 | 值 | 描述 |
| ---- | ---- | ---- |
| QAbstractItemModel::CheckIndexOption::NoOption | 0x0000 | 没有指定检查选项。|
| QAbstractItemModel::CheckIndexOption::IndexIsValid | 0x0001 | 传递给 [QAbstractItemModel::checkIndex()]() 的模型索引被检查为有效的模型索引。|
| QAbstractItemModel::CheckIndexOption::DoNotUseParent | 0x0002 | 不执行任何涉及到传递给 [QAbstractItemModel::checkIndex()]() 的父索引的使用的检查。|
| QAbstractItemModel::CheckIndexOption::ParentIsInvalid | 0x0004 | 传递给 [QAbstractItemModel::checkIndex()]() 的模型索引的父索引被检查为无效的模型索引。如果同时指定了此选项和 DoNotUseParent,则忽略此选项。|
该枚举是在 `Qt 5.11` 中引入或修改的。
`CheckIndexOptions` 类型是一个 [QFlags]()\<`CheckIndexOption`> 的类型定义。它存储一个或组合的 `CheckIndexOption` 值。
### LayoutChangeHint
**enum QAbstractItemModel::LayoutChangeHint**
这个枚举描述了模型改变布局的方式。
| 常量 | 值 | 描述 |
| ---- | ---- | ---- |
| QAbstractItemModel::NoLayoutChangeHint | 0 | 没有任何提示。 |
| QAbstractItemModel::VerticalSortHint | 1 | 正在对行进行排序。 |
| QAbstractItemModel::HorizontalSortHint | 2 | 正在对列进行排序。 |
注意,`VerticalSortHint` 和 `HorizontalSortHint` 表示项在同一父级中移动,而不是移动到模型中的不同父级,也没有过滤掉或过滤进来。
## 成员函数文档
### QAbstractItemModel
<font size=4> QAbstractItemModel::**QAbstractItemModel**([QObject]() *parent = nullptr) </font>
构造指定父类对象 `parent` 的抽象项模型。
### columnsAboutToBeInserted
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsAboutToBeInserted**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
在将列插入模型之前就发射此信号。新项将位于给定父项 `parent` 下的首 `first` 尾 `last`之间。
**注意:** 连接到这个信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 的实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。它可以用于信号连接,但不能由用户发射。
参见 [insertColumns()]() 和 [beginInsertColumns()]()。
### columnsAboutToBeMoved
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsAboutToBeMoved**(const [QModelIndex]() &sourceParent, **int** sourceStart, **int** sourceEnd, const [QModelIndex]() &destinationParent, **int** destinationColumn)</font>
模型中的列被移动之前发射该信号。将要移动的项是在给定 `sourceParent` 下在 `sourceStart` 和 `sourceEnd` 之间(包括首尾)的项。它们将从 `destinationColumn` 列开始移动到`destinationParent`。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveRows]()()。
### columnsAboutToBeRemoved
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsAboutToBeRemoved**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
模型中的列被移除之前发射该信号。将要移除的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [removeColumns]()() 和 [beginRemoveColumns]()()。
### columnsInserted
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsInserted**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
将列插入到模型之后发射该信号。新的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [insertColumns]()() 和 [beginInsertColumns]()()。
### columnsMoved
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsMoved**(const [QModelIndex]() &parent, **int** start, **int** end, const [QModelIndex]() &destination, **int** column)</font>
模型中的列被移动之后发射该信号。新的项是在给定 `parent` 下在 `start` 和 `end` 之间(包括首尾)的项。它们将从 `column` 列开始移动到`destination`。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveRows]()()。
### columnsRemoved
<font size=4>[ signal ] **void** QAbstractItemModel::**columnsRemoved**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
模型中的列被移除之后发射该信号。移除的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [removeColumns]()() 和 [beginRemoveColumns]()()。
### dataChanged
<font size=4>[ signal ] **void** QAbstractItemModel::**dataChanged**(const [QModelIndex]() &topLeft, const [QModelIndex]() &bottomRight, const [QVector]()<**int**> &roles = QVector<int>())</font>
现有的项的数据发生改变时发射该信号。
如果项是同一父项,则受影响的项是在 `topLeft` 和 `bottomRight`(包含)之间的项目。如果项没有相同的父项,则行为是不确定的。
当重新实现 [setData]()() 函数时,必须显示地发射该信号。
可选的 `roles` 参数可用于指定实际修改了哪些数据角色。`Roles` 参数中的向量为空,表示应将所有角色视为已修改。角色参数中元素的顺序没有任何关联。
参见 [headerDataChanged]()()、[setData]()() 和 [layoutChanged]()()。
### headerDataChanged
<font size=4>[ signal ] **void** QAbstractItemModel::**headerDataChanged**(const [Qt::Orientation]() &orientation, **int** first, **int** last)</font>
当标题改变时发射该信号。`orientation` 表示是横向标题还是竖向标题发生了改变。标题中从 `first` 到 `last` 的部分需要更新。
当重新实现 [setData]()() 函数时,必须显示地发射该信号。
如果要更改列数或行数,则不需要发出此信号,而可以使用 `begin/end` 函数(有关详细信息,请参见 [QAbstractItemModel]() 类描述中的子类化部分)。
参见 [headerData]()()、[setHeaderData]()() 和 [dataChanged]()()。
### layoutAboutToBeChanged
<font size=4>[ signal ] **void** QAbstractItemModel::**layoutAboutToBeChanged**(const [QList]()<[QPersistentModelIndex]()> &parents = QList<QPersistentModelIndex>(), [QAbstractItemModel::LayoutChangeHint]() hint = QAbstractItemModel::NoLayoutChangeHint)</font>
这个信号会在模型的布局改变之前发出。连接到这个信号的组件使用它来适应模型布局的变化。
在发出 `layoutAboutToBeChanged()` 之后,子类应该更新所有的持久化模型索引。
可选的 `parents` 参数用于提供更具体的通知关于模型布局的哪些部分正在被改变。空列表表示对整个模型的布局进行了更改。`parents` 列表中元素的顺序不重要。可选的 `hint` 参数用于提示模型重新布局时都发生了什么。
该函数在 `Qt 5.0` 中被引入。
参见 [layoutChanged]()() 和 [changePersistentIndex]()()。
### layoutChanged
<font size=4>[ signal ] **void** QAbstractItemModel::**layoutChanged**(const [QList]()<[QPersistentModelIndex]()> &parents = QList<QPersistentModelIndex>(), [QAbstractItemModel::LayoutChangeHint]() hint = QAbstractItemModel::NoLayoutChangeHint)</font>
每当模型公开的项的布局发生变化时,就会发出这个信号,例如,对模型进行排序时。当视图接收到该信号时,应更新项的布局来反映此更改。
当对 [QAbstractItemModel]() 或 [QAbstractProxyModel]() 进行子类化时,请确保在更改项顺序或更改要公开给视图的数据的结构之前发出 [layoutAboutToBeChanged]()() 信号,并在更改布局后发出 [layoutChanged]()() 信号。
可选的 `parents` 参数用于给出有关模型布局的哪些部分正在更改的具体的通知。空列表表示更改了整个模型的布局。`parents` 列表中元素的顺序并不重要。可选的 `hint` 参数用于提示模型重新布局时发生的情况。
子类应在发出 [layoutChanged]()() 信号之前更新所有持久模型索引。换句话说,当结构改变时:
- 发出 [layoutAboutToBeChanged]()
- 记住将会改变的 [QModelIndex]()
- 更新内部数据
- 调用 [changePersistentIndex]()()
- 发出 layoutChanged
该函数在 `Qt 5.0` 中被引入。
参见 [layoutAboutToBeChanged]()()、[dataChanged]()()、[headerDataChanged]()()、[modelReset]()() 和 [changePersistentIndex]()()。
### modelAboutToBeReset
<font size=4>[ signal ] **void** QAbstractItemModel::**modelAboutToBeReset**()</font>
当调用 [beginResetModel](#beginresetmodel)() 时,在模型的内部状态(例如持久模型索引)失效之前发出这个信号。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt 4.2` 中被引入。
参见 [beginResetModel](#beginresetmodel)() 和 [modelReset](#modelreset)()。
### modelReset
<font size=4>[ signal ] **void** QAbstractItemModel::**modelReset**()</font>
当调用 [endResetModel](#endresetmodel)() 时,在模型的内部状态(例如持久模型索引)失效之后发出这个信号。
注意,如果模型被重置,则应该认为之前从模型中检索的所有信息都是无效的。这包括但不限于 [rowCount](#rowcount)()、[columnCount](#columncount)()、[flags](#flags)()、通过 [data](#data)()检索的数据和 [roleNames](#rolenames)()。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt 4.1` 中被引入。
参见 [endResetModel](#endresetmodel)() 和 [modelAboutToBeReset](#modelabouttobereset)()。
### resetInternalData
<font size=4 weight="lighter">[ protected slot ] **void** QAbstractItemModel::**resetInternalData**()</font>
该槽函数在模型的内部数据被清除并被重置之后被调用。
该槽函数为具体代理模型的子类提供了便利,例如维护了额外的数据的 [QSortFilterProxyModel]() 的子类。
```cpp
class CustomDataProxy : public QSortFilterProxyModel
{
Q_OBJECT
public:
CustomDataProxy(QObject *parent)
: QSortFilterProxyModel(parent)
{
}
...
QVariant data(const QModelIndex &index, int role) override
{
if (role != Qt::BackgroundRole)
return QSortFilterProxyModel::data(index, role);
if (m_customData.contains(index.row()))
return m_customData.value(index.row());
return QSortFilterProxyModel::data(index, role);
}
private slots:
void resetInternalData()
{
m_customData.clear();
}
private:
QHash<int, QVariant> m_customData;
};
```
**注意:** 由于错误,该槽函数没有出现在 `Qt 5.0` 中。
该函数在 `Qt 4.8` 中被引入。
参见 [modelAboutToBeReset](#modelabouttobereset)() 和 [modelReset](#modelreset)()。
### revert
<font size=4>[ virtual slot ] **void** QAbstractItemModel::**revert**()</font>
让模型知道它应该丢弃缓存的信息。这个函数通常用于行编辑。
该函数在 `Qt 4.2` 中被引入。
参见 [submit](#submit)()。
### rowsAboutToBeInserted
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsAboutToBeInserted**(const [QModelIndex]() &parent, **int** start, **int** end)</font>
在将行插入模型之前就发出该信号。新项将位于给定 `parent` 项目下的包含 `start` 和 `end` 之间。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发出,而不能在子类代码中显式发出。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [insertRows](#insertrows)() 和 [beginInsertRows](#begininsertrows)()。
### rowsAboutToBeMoved
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsAboutToBeMoved**(const [QModelIndex]() &sourceParent, **int** sourceStart, **int** sourceEnd, const [QModelIndex]() &destinationParent, **int** destinationRow)</font>
模型中的行被移动之前发射该信号。将要移动的项是在给定 `sourceParent` 下在 `sourceStart` 和 `sourceEnd` 之间(包括首尾)的项。它们将从 `destinationRow` 列开始移动到`destinationParent`。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveRows](#beginmoverows)()。
### rowsAboutToBeRemoved
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsAboutToBeRemoved**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
模型中的行被移除之前发射该信号。将要移除的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [removeRows](#removerows)() 和 [beginRemoveRows](#beginremoverows)()。
### rowsInserted
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsInserted**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
将行插入到模型之后发射该信号。新的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [insertRows](#insertrows)() 和 [beginInsertRows](#begininsertrows)()。
### rowsMoved
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsMoved**(const [QModelIndex]() &parent, **int** start, **int** end, const [QModelIndex]() &destination, **int** column)</font>
模型中的行被移动之后发射该信号。新的项是在给定 `parent` 下在 `start` 和 `end` 之间(包括首尾)的项。它们将从 `column` 列开始移动到`destination`。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveRows](#beginmoverows)()。
### rowsRemoved
<font size=4>[ signal ] **void** QAbstractItemModel::**rowsRemoved**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
模型中的行被移除之后发射该信号。移除的项是在给定 `parent` 下在 `first` 和 `last` 之间(包括首尾)的项。
**注意:** 连接到该信号的组件使用它来适应模型尺寸的变化。它只能由 [QAbstractItemModel]() 实现发射,不能在子类代码中显式发射。
**注意:** 这是一个私有信号。仅用于信号连接,而不能由用户发射。
参见 [removeRows](#removerows)() 和 [beginRemoveRows](#beginremoverows)()。
### submit
<font size=4>[ virtual slot ] **void** QAbstractItemModel::**submit**()</font>
让模型知道它应该将缓存的信息提交到永久存储。这个函数通常用于行编辑。
如果没有错误,返回 `true`;否则返回 `false`。
参见 [revert](#revert)()。
### ~QAbstractItemModel
<font size=4>[ virtual ] **void** QAbstractItemModel::**~QAbstractItemModel**()</font>
销毁抽象项模型。
### beginInsertColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**beginInsertColumns**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
开始一个列插入操作。
在子类中重新实现 [insertColumns](#insertcolumns)() 时,必须在将数据插入模型的底层数据存储之前调用此函数。`parent` 索引对应于插入新列的父索引;`first` 和 `last` 是新列插入后的列号。
<div class="table"><table class="generic" width="100%">
<tbody><tr class="odd" valign="top"><td><img alt="Inserting columns" src="modelview-begin-insert-columns.png" width=326></td><td>指定要插入到模型项中的列的范围的第一个和最后一个列号。<p>例如,如图所示,我们在列4之前插入三列,所以 <i>first</i> 是4,<i>last</i> 是 6:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginInsertColumns</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">6</span></span><span class="pun">);</span></pre>
<p>这将插入三个新列作为列4、5和6。</p>
</td></tr>
<tr class="even" valign="top"><td><img alt="Appending columns" src="modelview-begin-append-columns.png"></td><td>要追加列,请将它们插入到最后一列之后。例如,如图所示,我们将三列附加到一个包含六列的集合(以列5结尾),因此 <i>first</i> 是 6 and <i>last</i> 是 8:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginInsertColumns</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">6</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">8</span></span><span class="pun">);</span></pre>
<p>这将追加两个新列作为列6、7和8。</p>
</td></tr>
</tbody></table></div>
**注意:** 此函数发出 [columnAboutToBeInserted](#columnsabouttobeinserted)() 信号,在插入数据之前,已连接的视图(或代理)必须处理该信号。否则,视图可能会以无效状态结束。
参见 [endInsertColumns](#endinsertcolumns)()。
### beginInsertRows
<font size=4>[ protected ] **void** QAbstractItemModel::**beginInsertRows**(const [QModelIndex]() &parent, **int** first, **int** last)</font>
开始一个行插入操作。
在子类中重新实现 [insertRows](#insertrows)() 时,必须在将数据插入模型的底层数据存储之前调用此函数。`parent` 索引对应于插入新列的父索引;`first` 和 `last` 是新行插入后的行号。
<div class="table"><table class="generic" width="100%">
<tbody><tr class="odd" valign="top"><td><img alt="Inserting rows" src="modelview-begin-insert-rows.png" width=274></td><td>为要插入模型中项的行范围指定第一行和最后一行。
例如,如图所示,我们在第2行之前插入三行,因此<i>first</i> 是2,<i>first</i> 是4:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginInsertRows</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="pun">);</span></pre>
<p>这将插入三行新行,即第2、3和4行。</p>
</td></tr>
<tr class="even" valign="top"><td><img alt="Appending rows" src="modelview-begin-append-rows.png"></td><td>要追加行,请将它们插入到最后一行之后。例如,如图所示,我们将两行附加到一个包含4个现有行的集合(以第3行结束),因此 <i>first</i> 是4,<i>last</i> 是5: </p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginInsertRows</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">5</span></span><span class="pun">);</span></pre>
<p>这将追加两个新行作为第4行和第5行。</p>
</td></tr>
</tbody></table></div>
**注意:** 此函数发出 [rowsAboutToBeInserted](#rowsabouttobeinserted)() 信号,在插入数据之前,已连接的视图(或代理)必须处理该信号。否则,视图可能会以无效状态结束。
参见 [endInsertRows](#endinsertrows)()。
### beginMoveColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**beginMoveColumns**(const [QModelIndex]() &sourceParent, **int** sourceFirst, **int** sourceLast, const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
开始一个列移动操作。
当重新实现子类时,此方法简化了模型中实体的移动。此方法负责在模型中移动持久索引,否则您将需要自己执行此操作。使用 `beginMoveColumns` 和 [endMoveColumns](#endmovecolumns)() 是直接发送与 [changePersistentIndex](#changepersistentindex)() 一起的 [layoutAboutToBeChanged](#layoutabouttobechanged)() 和 [layoutChanged](#layoutchanged)() 的另一种选择。
`sourceParent` 索引对应于从其移出列的父级;`sourceFirst` 和 `sourceLast` 是要移动的列的第一列和最后一列。`destinationParent` 索引对应于将这些列移入的父级。`destinationChild` 是要将列移动到的列。也就是说,`sourceParent` 中 `sourceFirst` 列的索引将成为 `destinationParent` 中的 `destinationChild` 列,然后是所有其他列,直到 `sourceLast`。
但是,当在同一父目录下移动列时(`sourceParent` 和 `destinationParent` 是相等的),这些列将被放置在 `destinationChild` 索引之前。也就是说,如果您希望移动列0和1,使它们变成列 1 和列 2,`destinationChild` 应该是 3。在本例中,源列 `i` (位于 `sourceFirst` 和 `sourceLast` 之间)的新索引等于(`destinationChild-sourceLast-1+i`)。
注意,如果 `sourceParent` 和 `destinationParent` 是相同的,您必须确保 `destinationChild` 不在 `sourceFirst` 和 `sourceLast + 1` 的范围内。还必须确保不会尝试将列移动到它自己的子列或祖先列中。如果任一条件为真,此方法将返回 `false`,在这种情况下,应中止移动操作。
该函数在 `Qt4.6` 中被引入。
参见 [endMoveColumns](#endmovecolumns)()。
### beginMoveRows
<font size=4>[ protected ] **void** QAbstractItemModel::**beginMoveRows**(const [QModelIndex]() &sourceParent, **int** sourceFirst, **int** sourceLast, const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
开始一个行移动操作。
当重新实现子类时,此方法简化了模型中实体的移动。此方法负责在模型中移动持久索引,否则您将需要自己执行此操作。使用 `beginMoveRows` 和 `endMoveRows` 是直接发送与 [changePersistentIndex](#changepersistentindex)() 一起的 [layoutAboutToBeChanged](#layoutabouttobechanged)() 和 [layoutChanged](#layoutchanged)() 的另一种选择。
`sourceParent` 索引对应于从其移出行的父级;`sourceFirst` 和 `sourceLast` 是要移动的行的第一行和最后一行。`destinationParent` 索引对应于将这些行移入的父级。`destinationChild` 是要将行移动到的行。也就是说,`sourceParent` 中的 `sourceFirst` 行的索引将成为 `destinationParent` 中的 `destinationChild` 行,然后是所有其他行,直到 `sourceLast`。
但是,当在同一父目录下移动列时(`sourceParent` 和 `destinationParent` 是相等的),这些行将被放置在 `destinationChild` 索引之前。也就是说,如果您希望移动列0和1,使它们变成行 1 和行 2,`destinationChild` 应该是 3。在本例中,源行 `i` (位于 `sourceFirst` 和 `sourceLast` 之间)的新索引等于(`destinationChild-sourceLast-1+i`)。
注意,如果 `sourceParent` 和 `destinationParent` 是相同的,您必须确保 `destinationChild` 不在 `sourceFirst` 和 `sourceLast + 1` 的范围内。还必须确保不会尝试将行移动到它自己的子列或祖先行中。如果任一条件为真,此方法将返回 `false`,在这种情况下,应中止移动操作。
<div class="table"><table class="generic" width="100%">
<tbody><tr class="odd" valign="top"><td><img alt="Moving rows to another parent" src="modelview-move-rows-1.png" width=800></td><td>指定源父行中您希望在模型中移动的行跨度的第一行和最后一行编号。还要在目标父级中指定要将范围内的行移动到的行。例如,如图所示,我们将源中的第 2 行到第 3 行移动了三行,因此 <i>sourceFirst</i> 为 2,<i>sourceLast</i> 为 4。我们将这些项移动到目标的第2行上方,因此 <i>destinationChild</i> 为2。</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginMoveRows</span><span class="pun">(</span><span class="pln">sourceParent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> destinationParent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="pun">);</span></pre>
<p>这会将源中的三行第 2、3 和 4 行移动到目标中的 2、3 和 4 行。其他受影响的同级项也因此被移位。</p>
</td></tr>
<tr class="even" valign="top"><td><img alt="Moving rows to append to another parent" src="modelview-move-rows-2.png"></td><td>若要将行追加到另一个父元素,请将它们移到最后一行的后面。例如,如图所示,我们将三行移动到一个包含 6 个现有行的集合中(以第 5 行结束),因此 <i>destinationChild</i> 为6:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginMoveRows</span><span class="pun">(</span><span class="pln">sourceParent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> destinationParent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">6</span></span><span class="pun">);</span></pre>
<p>这会将目标行移到目标父级的末尾,分别为 6、7 和 8。</p>
</td></tr>
<tr class="odd" valign="top"><td><img alt="Moving rows in the same parent up" src="modelview-move-rows-3.png"></td><td>要在同一父级中移动行,请指定要将其移动到的行。
例如,如图所示,我们将一项从第 2 行移至第 0 行,因此 <i>sourceFirst</i> 和 <i>sourceLast</i> 为2,<i>destinationChild</i> 为0。</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginMoveRows</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">0</span></span><span class="pun">);</span></pre>
<p>注意,其他行可能会相应移位。另请注意,在同一父级中移动项时,请勿尝试无效移动或无操作移动。在上面的示例中,项 2 位于移动之前的第 2 行,因此无法将其移动到第 2 行(已经存在)或第 3 行(空操作,因为第 3 行意味着已经在第 3 行之上)</p>
</td></tr>
<tr class="even" valign="top"><td><img alt="Moving rows in the same parent down" src="modelview-move-rows-4.png"></td><td>要在同一父级中移动行,请指定要将其移动到的行。例如,如图所示,我们将一项从第 2 行移至第 4 行,因此 <i>sourceFirst</i> 和 <i>sourceLast</i> 为2,<i>destinationChild</i> 为4。</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginMoveRows</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="pun">);</span></pre>
<p>注意,其他行可能会相应移位。</p>
</td></tr>
</tbody></table></div>
该函数在 `Qt4.6` 中被引入。
参见 [endMoveRows](#endmoverows)()。
### beginRemoveColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**beginRemoveColumns**(const [QModelIndex]() &parent, int first, int last)</font>
开始一个列移除操作。
在子类中重新实现 [removeColumns](#removecolumns)() 时,必须在从模型的底层数据存储中删除数据之前调用此函数。`parent` 索引对应于删除新列的父索引; `first` 和 `last` 是要删除的第一个和最后一个列的列号。
<div class="table"><table class="generic" width="100%">
<tbody><tr class="odd" valign="top"><td><img alt="Removing columns" src="modelview-begin-remove-columns.png" width=482></td><td>指定要从模型中的项中删除的列的范围的第一个和最后一个列号。例如,如图所示,我们将这三列从第4列移到第6列,因此 <i>first</i> 是4,<i>last</i> 是6:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginRemoveColumns</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">4</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">6</span></span><span class="pun">);</span></pre>
</td></tr>
**注意:** 此函数发出 [columnAboutToBeRemoved]()() 信号,在删除数据之前,已连接的视图(或代理)必须处理该信号。否则,视图可能会以无效状态结束。
参见 [endRemoveColumns](#endremovecolumns)()。
</tbody></table></div>
### beginRemoveRows
<font size=4>[ protected ] **void** QAbstractItemModel::**beginRemoveRows**(const [QModelIndex]() &parent, int first, int last)</font>
开始一个行移除操作。
在子类中重新实现 [removeRows](#removerows)() 时,必须在从模型的基础数据存储中删除数据之前调用此函数。
`parent` 引对应于从中删除新行的父索引;`first` 和 `last` 是要删除的行的行号。
<div class="table"><table class="generic" width="100%">
<tbody><tr class="odd" valign="top"><td><img alt="Removing rows" src="modelview-begin-remove-rows.png" width=250></td><td>指定要从模型中的项中删除的行范围的第一个和最后一个行号。例如,如图所示,我们将从第 2 行到第 3 行的两行删除,因此 <i>first</i> 是 2,<i>last</i> 是 3:</p>
<pre class="cpp prettyprint prettyprinted" style=""><span class="pln">beginRemoveRows</span><span class="pun">(</span><span class="pln">parent</span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">2</span></span><span class="operator"><span class="pun">,</span></span><span class="pln"> </span><span class="number"><span class="lit">3</span></span><span class="pun">);</span></pre>
</td></tr>
</tbody></table></div>
**注意:** 此函数发出 [rowsAboutToBeRemoved](#rowsabouttoberemoved)() 信号,连接的视图(或代理)必须在删除数据之前处理该信号。否则,视图可能会以无效状态结束。
参见 [endRemoveRows](#endremoverows)()。
### beginResetModel
<font size=4>[ protected ] **void** QAbstractItemModel::**beginResetModel**()</font>
开始模型重置操作。
重置操作会在任何附加的视图中将模型重置为当前状态。
**注意:** 附加到这个模型的任何视图都将被重置。
当一个模型被重置时,这意味着以前从该模型报告的任何数据现在都是无效的,必须再次进行查询。这也意味着当前项和任何选定项都将无效。当模型从根本上更改其数据时,有时只需调用此函数比在底层数据源或其结构发生更改时发出 [dataChanged](#datachanged)() 通知其他组件更容易。
在重新设置模型或代理模型中的任何内部数据结构之前,必须调用此函数。
这个函数发出信号 [modelAboutToBeReset](#modelabouttobereset)()。
该函数在 `Qt4.6` 中被引入。
参见 [modelAboutToBeReset](#modelabouttobereset)()、[modelReset](#modelreset)() 和 [endResetModel](#endresetmodel)()。
### buddy
<font size=4>[ virtual ] **void** QAbstractItemModel::**buddy**(const [QModelIndex]() &index) const</font>
返回由 `index` 表示的项的伙伴的模型索引。当用户想要编辑项目时,视图将调用此函数以检查是否应改为编辑模型中的另一个项。然后,视图将使用伙伴项返回的模型索引构造一个委托。
此功能的默认实现将每个项都作为自己的伙伴。
### canDropMimeData
<font size=4>[ virtual ] **bool** QAbstractItemModel::**canDropMimeData**(const [QMimeData]() *data, [Qt::DropAction]() action, **int** row, **int** column, const [QModelIndex]() &parent) const</font>
如果模型接受放置 `data`,则返回 `true`。这个默认实现只检查 [mimeTypes]()() 列表中数据是否至少有一种格式,以及操作是否在模型的 [supportedDropActions]()() 中。
如果您想要测试是否可以在 `row`、`column`、`parent`节点上放置 `data`,请在自定义模型中重新实现此函数。如果您不需要该测试,那么就没有必要重新实现此函数。
参见 [dropMimeData](#dropmimedata)() 和 [在项视图中使用拖放](../../M/Model_View_Programming/Model_View_Programming.md#在项视图中使用拖放)。
### canFetchMore
<font size=4>[ virtual ] **bool** QAbstractItemModel::**canFetchMore**(const [QModelIndex]() &parent) const</font>
如果在 `parent` 索引下有更多可用的数据返回 `true`;否则返回 `fasle`;
默认的实现总是返回 `false`。
如果 `canFetchMore()` 返回 `true`,则应该调用 [fetchMore](#fetchmore)() 函数。比如 [QAbstractItemView]() 就是这样做的。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [fetchMore](#fetchmore)()。
### changePersistentIndex
<font size=4>[ protected ] **void** QAbstractItemModel::**changePersistentIndex**(const [QModelIndex]() &from, const [QModelIndex]() &to)</font>
将等于给定的 `from` 的 [QPersistentModelIndex]()() 模型索引更改为 `to` 模型索引。
如果没有找到与给定的模型索引 `from` 相等的持久模型索引,则什么也不会改变。
如果 `canFetchMore()` 返回 `true`,则应该调用 [fetchMore](#fetchmore)() 函数。比如 [QAbstractItemView]() 就是这样做的。
参见 [persistentIndexList](#persistentindexlist)() 和 [changePersistentIndexList](#changepersistentindexlist)()。
### changePersistentIndexList
<font size=4>[ protected ] **void** QAbstractItemModel::**changePersistentIndexList**(const [QModelIndexList ]() &from, const [QModelIndexList ]() &to)</font>
将等于给定的 `from` 的 [QPersistentModelIndex]()()es 模型索引列表更改为 `to` 模型索引列表。
如果没有找到与给定的模型索引 `from` 相等的持久模型索引,则什么也不会改变。
该函数在 `Qt4.1` 中被引入。
参见 [persistentIndexList](#persistentindexlist)() 和 [changePersistentIndex](#changepersistentindex)()。
### checkIndex
<font size=4>**bool** QAbstractItemModel::**checkIndex**(const [QModelIndex]() &index, [QAbstractItemModel::CheckIndexOptions]() options = CheckIndexOption::NoOption) const</font>
此函数检查索引是否为此模型的合法模型索引。 合法模型索引要么是无效的模型索引,要么是具有以下所有条件的有效模型索引:
- `index` 的模型就是 `this`;
- `index` 的行数大于等于零;
- `index` 的行数小于父索引的行数;
- `index` 的列数大于等于零;
- `index` 的列数小于父索引的列数。
`options` 参数可能会改变其中一些检查。如果 `options` 包含 `IndexIsValid`,那么 `index` 必须是一个有效的索引;这在重新实现 [data](#data)() 或 [setData](#setdata)() 等需要有效索引的函数时非常有用。
如果 `options` 包含 `DoNotUseParent`,那么将调用 [parent](#parent)() 的检查将被省略;允许在重新实现的 [parent](#parent)() 函数中调用此函数(否则,将导致无穷递归和崩溃)。
如果 `options` 不包含 `DoNotUseParent`,但包含 `IndexIsValid`,那么将执行额外的检查:检查父索引是否有效。这在实现平面模型(如列表或表)时非常有用,在这种情况下,模型索引不应该具有有效的父索引。
该函数如果检查成功返回 `true`,否则返回 `false`。允许在 `Q_ASSERT` 和类似的其他调试机制中使用该函数。如果某些检查失败,则将在 `qt.core.qabstractitemmodel.checkindex` 日志记录类别中显示一条警告消息,其中包含一些可能对调试失败有用的信息。
**注意:** 这个函数是一个调试助手,用于实现您自己的项模型。在开发复杂模型时,以及在构建复杂的模型层次结构时(例如使用代理模型),调用这个函数来捕获传递给某个 [QAbstractItemModel]()() `API` 的非法模型索引(如上定义)相关的bug是很有用的。
**警告:** 请注意,将非法索引传递给项模型是未定义的行为,因此应用程序必须避免这样做,并且不能依赖于项模型可以用来优雅地处理非法索引的任何“防御性”编程。
该函数在 `Qt5.11 中被引入。
参见 [QModelIndex]()。
### columnCount
<font size=4>[ pure virtual ] **int** QAbstractItemModel::**columnCount**(const [QModelIndex]() &parent = QModelIndex()) const</font>
返回给定 `parent` 索引的子项的列的数量。
在大多数子类中,列的数量独立于 `parent`。
例如:
```cpp
int DomModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 3;
}
```
**注意:** 在实现基于表的模型时,当父模型有效时,`columnCount()` 应该返回 0。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
该函数在 `Qt4.1` 中被引入。
参见 [rowCount](#rowcount)()。
### createIndex
<font size=4>[ protected ] **[QModelIndex]()** QAbstractItemModel::**createIndex**(**int** row, **int** column, **void** *ptr = nullptr) const</font>
使用内部指针 `ptr` 为给定的 `row` 和 `column` 创建模型索引。
当使用 [QSortFilterProxyModel]() 时,它的索引有自己的内部指针。不建议在模型外部访问这个内部指针。使用 [data]()() 函数代替。
这个函数提供了一个一致的接口,模型子类必须使用这个接口来创建模型索引。
参见 [QModelIndex::internalId]()()。
### data
<font size=4>[ pure virtual ] **[QVariant]()** QAbstractItemModel::**data**(const [QModelIndex]() &index, **int** role = Qt::DisplayRole) const</font>
返回指定角色 `role` 和 索引 `index` 的项数据。
**注意:** 如果没有要返回的值,则返回无效的 [QVariant](),而不是返回 0。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [Qt::ItemDataRole]()、[setData](#setdata)() 和 [headerData](#headerdata)()。
### dropMimeData
<font size=4>[ virtual ] **bool** QAbstractItemModel::**dropMimeData**(const [QMimeData]() *data, [Qt::DropAction]() action, **int** row, **int** column, const [QModelIndex]() &parent) const</font>
处理以给定操作 `action` 结束的拖放操作提供的数据 `data`。
如果数据和操作被模型处理了则返回 `true`,否则返回 `false`。
指定的行 `row`、列 `column` 和父索引 `parent` 指示模型中操作结束的项的位置。在正确的位置完成动作是模型的责任。
例如,[QTreeView]() 中的一个项上的拖放操作可以导致新项作为行 `row`、列 `column` 和父索引 `parent` 指定的项的子项插入,或者作为项的兄弟项插入。
当行 `row` 和列 `column` 为 -1 时,这意味着放置的数据应该被认为是直接在 `parent` 上放置的。通常这意味着将数据附加为父项 `parent` 的子项。如果行 `row` 和列 `column` 大于或等于零,则表示放置发生在指定父索引 `parent` 的 `row` 和列 `column` 的前面。
调用 [mimeTypes]()() 成员来获取可接受的 `MIME` 类型列表。这个默认实现假定 [mimeTypes]()() 是默认实现,它返回一个默认 `MIME` 类型。如果您在自定义模型中重新实现 [mimeTypes]()() 以返回多个 `MIME` 类型,那么您必须重新实现此函数以使用它们。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [supportedDropActions]()、[canDropMimeData](#candropmimedata)() 和 [在项视图中使用拖放](../../M/Model_View_Programming/Model_View_Programming.md#在项视图中使用拖放)。
### endInsertColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**endInsertColumns**()</font>
结束列插入操作。
在子类中重新实现 [insertColumns](#insertcolumns)()时,必须在将数据插入模型的底层数据存储之后调用此函数。
参见 [beginInsertColumns](#begininsertcolumns)()。
### endInsertRows
<font size=4>[ protected ] **void** QAbstractItemModel::**endInsertRows**()</font>
结束行插入操作。
在子类中重新实现 [insertRows](#insertrows)()时,必须在将数据插入模型的底层数据存储之后调用此函数。
参见 [beginInsertRows](#begininsertrows)()。
### endMoveColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**endMoveColumns**()</font>
结束列移动操作。
在实现子类时,必须在模型的底层数据存储中移动数据之后调用此函数。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveColumns](#beginmovecolumns)()。
### endMoveRows
<font size=4>[ protected ] **void** QAbstractItemModel::**endMoveRows**()</font>
结束行移动操作。
在实现子类时,必须在模型的底层数据存储中移动数据之后调用此函数。
该函数在 `Qt4.6` 中被引入。
参见 [beginMoveRows](#beginmoverows)()。
### endRemoveColumns
<font size=4>[ protected ] **void** QAbstractItemModel::**endRemoveColumns**()</font>
结束列删除操作。
在子类中重新实现 [removeColumns](#removecolumns)() 时,必须在从模型的底层数据存储中删除数据之后调用此函数。
参见 [beginRemoveColumns](#beginremovecolumns)()。
### endRemoveRows
<font size=4>[ protected ] **void** QAbstractItemModel::**endRemoveRows**()</font>
结束行删除操作。
在子类中重新实现 [removeRows](#removerows)() 时,必须在从模型的底层数据存储中删除数据之后调用此函数。
参见 [beginRemoveRows](#beginremoverows)()。
### endResetModel
<font size=4>[ protected ] **void** QAbstractItemModel::**endResetModel**()</font>
完成模型重置操作。
在重置模型或代理模型中的任何内部数据结构后,必须调用此函数。
该函数发出 [modelReset](#modelreset)() 信号。
该函数在 `Qt4.6` 中被引入。
参见 [beginResetModel](#beginresetmodel)()。
### fetchMore
<font size=4>[ virtual ] **void** QAbstractItemModel::**fetchMore**(const [QModelIndex]() &parent)</font>
获取指定的 `parent` 父索引的项的任何可用的数据。
如果递增地填充模型,则需要重新实现该函数。
该函数的默认实现没有做任何事情。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [canFetchMore](#canfetchmore)()。
### flags
<font size=4>[ virtual ] **[Qt::ItemFlags]()** QAbstractItemModel::**flags**(const [QModelIndex]() &index) const</font>
返回给定索引的项标志。
基类的实现返回启用项(`ItemIsEnabled`)和允许选择项(`ItemIsSelectable`)的标志的组合。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [Qt::ItemFlags]()。
### hasChildren
<font size=4>[ virtual ] **[Qt::ItemFlags]()** QAbstractItemModel::**hasChildren**(const [QModelIndex]() &parent = QModelIndex()) const</font>
如果父索引 `parent` 有任何子项则返回 `true`,否则返回 `false`。
在父索引上使用 [rowCount](#rowcount)() 来查找子项的数量。
注意,如果一个索引设置了 [Qt::ItemNeverHasChildren]() 标志,那么用该索引调用该方法是未定义的行为。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [parent](#parent)() 和 [index](#index)()。
### hasIndex
<font size=4>[ virtual ] **bool** QAbstractItemModel::**hasIndex**(**int** row, **int** column, const [QModelIndex]() &parent = QModelIndex()) const</font>
如果模型返回一个指定父索引 `parent`、行 `row` 和列 `column` 的有效 [QModelIndex](),则返回 `true`,否则返回 `false`。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
### headerData
<font size=4>[ virtual ] **[QVariant]()** QAbstractItemModel::**headerData**(**int** section, [Qt::Orientation]() orientation, **int** role = Qt::DisplayRole) const</font>
返回标题中具有给定 `orientation` 和 `section` 的数据。
对于水平标题,节号对应于列号。类似地,对于垂直标题,节号对应于行号。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [Qt::ItemDataRole]()、[setHeaderData](#setheaderdata)() 和 [QHeaderView]()。
### index
<font size=4>[ pure virtual ] **[QModelIndex]()** QAbstractItemModel::**index**(**int** row, **int** column, const [QModelIndex]() &parent = QModelIndex()) const</font>
返回模型中指定 `row`、`column` 和 `parent` 索引的项的索引。
在子类中重新实现此函数时,调用 [createIndex](#createindex)() 来生成模型索引,其他组件可以使用这些索引来引用模型中的项。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [createIndex](#createindex)()。
### insertColumn
<font size=4>**bool** QAbstractItemModel::**insertColumn**(**int** column, const [QModelIndex]() &parent = QModelIndex()) const</font>
在指定 `parent` 索引的子项的指定 `column` 之前插入一列。
如果插入了该列,则返回 `true`;否则,返回 `false`。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [insertColumns](#insertcolumns)()、[insertRow](#insertrow)() 和 [removeColumn](#removecolumn)()。
### insertColumns
<font size=4>[ virtual ] **bool** QAbstractItemModel::**insertColumns**(**int** column, **int** count, const [QModelIndex]() &parent = QModelIndex()) const</font>
在支持此功能的模型上,在模型中的给定 `column` 之前插入 `count` 列新列。每个新列中的项将是由父模型索引 `parent` 表示的项的子项目。
如果 `column` 为 0,则这些列将添加到任何现有列的前面。
如果 `column` 为 [columnCount](#columncount)(),则将这些列追加到任何现有列之后。
如果 `parent` 没有子项,插入带有 `count` 列的单行。
如果列成功插入,则返回 `true`,否则返回 `false`。
基类的实现没有做任何事情,并且返回 `false`。
如果您实现了自己的模型,希望支持插入,则可以重新实现此函数。或者,您可以提供自己的 `API` 来更改数据。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [insertRows](#insertrows)()、[removeColumns](#removecolumns)()、[beginInsertColumns](#begininsertcolumns)() 和 [endInsertColumns](#begininsertcolumns)()。
### insertRow
<font size=4>**bool** QAbstractItemModel::**insertRow**(**int** row, const [QModelIndex]() &parent = QModelIndex()) const</font>
在指定 `parent` 索引的子项的指定 `row` 之前插入一列。
**注意:** 该函数调用了虚函数 [insertRows](#insertrows)()。
如果插入了该行,则返回 `true`;否则,返回 `false`。
参见 [insertRows](#insertrows)()、[insertColumn](#insertcolumn)() 和 [removeRow](#removerow)()。
### insertRows
<font size=4>[ virtual ] **bool** QAbstractItemModel::**insertRows**(**int** row, **int** count, const [QModelIndex]() &parent = QModelIndex()) const</font>
**注意:** 基类的实现没有做任何事情,并且返回 `false`。
在支持此功能的模型上,将 `count` 行插入模型中给定的行之前。新行中的项将是由父模型索引 `parent` 表示的项的子项。
如果 `row` 为 0,则这些行将添加到任何现有列的前面。
如果 `row` 为 [rowCount](#rowcount)(),则将这些列追加到任何现有行之后。
如果 `parent` 没有子项,插入带有 `count` 行的单列。
如果列成功插入,则返回 `true`,否则返回 `false`。
如果您实现了自己的模型,希望支持插入,则可以重新实现此函数。或者,您可以提供自己的 `API` 来更改数据。在任何一种情况下,您都需要调用 [beginInsertRows](#begininsertrows)() 和 [endInsertRows](#endinsertrows)() 来通知其他组件模型已经更改
参见 [insertColumns](#insertcolumns)()、[removeRows](#removerows)()、[beginInsertRows](#begininsertrows)() 和 [endInsertRows](#endinsertrows)()。
### itemData
<font size=4>[ virtual ] [QMap]()<**int**, [QVariant]()> QAbstractItemModel::**itemData**(const [QModelIndex]() &index) const</font>
为给定索引 `index` 处的项返回具有模型中所有预定义角色值的 `map`。
如果希望扩展此函数的默认行为以在 `map` 中包含自定义角色,请重新实现此函数。
参见 [setItemData](#setitemdata)()、[Qt::ItemDataRole]() 和 [data](#data)()。
### match
<font size=4>[ virtual ] [QModelIndexList]() QAbstractItemModel::**match**(const [QModelIndex]() &start, **int** role, const [QVariant]() &value, **int** hits = 1, [Qt::MatchFlags]() flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const</font>
返回一列项的索引,这些索引在 `start` 索引的列中并且该索引下的数据在给定角色下存储的数据与指定值匹配。执行搜索的方式由给定的 `flags` 定义。返回的列表可能是空的。还要注意,如果使用了代理模型,列表中结果的顺序可能与模型中的顺序不一致。不能依赖结果的顺序。
搜索从 `start` 索引开始,直到匹配数据项的数量等于 `hits`,搜索到达最后一行,或者再次搜索到达start—这取决于是否在 `flags` 中指定了 `MatchWrap`。如果希望搜索所有匹配项,请使用 `hits = -1`。
默认情况下,此函数将对所有项执行基于字符串的包装比较,搜索以 `value` 指定的搜索项开头的项。
**注意:** 这个函数的默认实现只搜索列。重新实现此函数以包含不同的搜索行为。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
### mimeData
<font size=4>[ virtual ] [QMimeData]() QAbstractItemModel::**mimeData**(const [QModelIndexList]() &indexes) const</font>
返回一个对象,该对象包含与指定索引 `indexes` 列表对应的序列化数据项。用于描述编码数据的格式是从 [mimeTypes](#mimetypes)() 函数获得的。这个默认实现使用 [mimeTypes](#mimetypes)() 的默认实现返回的默认 `MIME` 类型。如果您在自定义模型中重新实现 [mimeTypes](#mimetypes)() 以返回更多 `MIME` 类型,那么重新实现此函数以使用它们。
如果 `indexes` 为空,或者没有受支持的 `MIME` 类型,则返回 0,而不是序列化的空列表。
参见 [mimeTypes](#mimetypes)() 和 [dropMimeData](#dropmimedata)()。
### mimeTypes
<font size=4>[ virtual ] [QStringList]() QAbstractItemModel::**mimeTypes**() const</font>
返回允许的 `MIME` 类型的列表。默认情况下,内置模型和视图使用内部 `MIME` 类型:`application / x-qabstractitemmodeldatalist`。
在自定义模型中实现拖放支持时,如果您将以默认内部 `MIME` 类型以外的格式返回数据,请重新实现此函数以返回您的 `MIME` 类型列表。
如果在自定义模型中重新实现这个函数,还必须重新实现调用它的成员函数: [mimeData](#mimedata)() 和 [dropMimeData](#dropmimedata)()。
参见 [mimeData](#mimedata)() 和 [dropMimeData](#dropmimedata)()。
### moveColumn
<font size=4>**bool** QAbstractItemModel::**moveColumn**(const [QModelIndex]() &sourceParent, **int** sourceColumn, const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
在支持此功能的模型上,将 `sourceColumn从sourceParent` 移到 `destinationParent` 下的 `destinationChild`。
如果列被成功移动,则返回 `true`;否则返回 `false`。
参见 [moveColumns](#movecolumns)() 和 [moveRow](#moverow)()。
### moveColumns
<font size=4>[ virtual ] **bool** QAbstractItemModel::**moveColumns**(const [QModelIndex]() &sourceParent, **int** sourceColumn, **int** count, const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
在支持此功能的模型上,将 `count` 列从父索引 `sourceParent` 下的给定 `sourceColumn` 移到父索引 `destinationParent` 下的 `destinationChild` 列。
如果列被成功移动,则返回 `true`;否则返回 `false`。
基类的实现没有做任何事情,并且返回 `false`。
如果实现自己的模型,则如果要支持移动,则可以重新实现此功能。另外,您可以提供自己的 `API` 来更改数据。
参见 [beginMoveColumns](#beginmovecolumns)() 和 [endMoveColumns](#endmovecolumns)()。
### moveRow
<font size=4>**bool** QAbstractItemModel::**moveRow**(const [QModelIndex]() &sourceParent, **int** sourceRow const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
在支持此功能的模型上,将 `sourceColumn从sourceParent` 移到 `destinationParent` 下的 `destinationChild`。
如果行被成功移动,则返回 `true`;否则返回 `false`。
参见 [moveRows](#moverows)() 和 [moveColumn](#movecolumn)()。
### moveRows
<font size=4>[ virtual ] **bool** QAbstractItemModel::**moveRows**(const [QModelIndex]() &sourceParent, **int** sourceRow, **int** count, const [QModelIndex]() &destinationParent, **int** destinationChild)</font>
在支持此功能的模型上,将 `count` 行从父索引 `sourceParent` 下的给定 `sourceColumn` 移到父索引 `destinationParent` 下的 `destinationChild` 行。
如果行被成功移动,则返回 `true`;否则返回 `false`。
基类的实现没有做任何事情,并且返回 `false`。
如果实现自己的模型,则如果要支持移动,则可以重新实现此功能。另外,您可以提供自己的 `API` 来更改数据。
参见 [beginMoveRows](#beginmoverows)() 和 [endMoveRows](#endmoverows)()。
### parent
<font size=4>[ pure virtual ] **bool** QAbstractItemModel::**parent**(const [QModelIndex]() &index) const</font>
返回具有给定索引 `index` 的模型项的父项。如果该项没有父项,则返回无效的 [QModelIndex]()。
在公开树数据结构的模型中使用的常见约定是,只有第一列中的项才有子级。对于这种情况,当在子类中重新实现此函数时,返回的 [QModelIndex]() 的列将为0。
在子类中重新实现这个函数时,要小心避免调用 [QModelIndex]() 成员函数,比如 [QModelIndex::parent]()(),因为模型的索引将简单地调用实现,从而导致无限递归。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [createIndex](#createindex)()。
### persistentIndexList
<font size=4>[ protected ] [QModelIndexList]() QAbstractItemModel::**persistentIndexList**() const</font>
返回作为模型中的持久索引存储的索引列表。
该函数在 `Qt4.2` 中被引入。
### removeColumn
<font size=4>**bool** QAbstractItemModel::**removeColumn**(**int** column, const [QModelIndex]() &parent = QModelIndex())</font>
从指定的父项 `parent` 的子项中删除给定的列 `column`。
如果删除了该列,则返回 `true`;否则返回 `false`。
参见 [removeColumns](#removecolumns)()、[removeRow](#removerow)()和[insertColumn](#insertcolumn)()。
### removeColumns
<font size=4>[ virtual ] **bool** QAbstractItemModel::**removeColumns**(**int** column, **int** count, const [QModelIndex]() &parent = QModelIndex())</font>
在支持此功能的模型上,从模型中删除以父项 `parent` 下给定列 `column` 开头的 `count` 列。
如果列被成功删除,返回头 `true`;否则返回 `false`。
基类的实现没有做任何事情并返回了 `false`。
如果实现自己的模型,要支持删除,则可以重新实现此函数。 另外,您可以提供自己的 `API` 来更改数据。
参见 [removeColumn](#removecolumn)()、[removeRows](#removerows)()、[insertColumns](#insertcolumns)()、[beginRemoveColumns](#beginremovecolumns)() 和 [endRemoveColumns](#endremovecolumns)()。
### removeRow
<font size=4>**bool** QAbstractItemModel::**removeRow**(**int** row, const [QModelIndex]() &parent = QModelIndex())</font>
从指定的父项 `parent` 的子项中删除给定的行 `row`。
如果删除了该行,则返回 `true`;否则返回 `false`。
这是一个调用 [removeRows](#removerows)()的便利函数。[QAbstractItemModel]() 的 [removeRows](#removerows)()的实现不做任何事情。
参见 [removeRows](#removerows)()、[removeColumn](#removecolumn)()和[insertRow](#insertrow)()。
### removeRows
<font size=4>[ virtual ] **bool** QAbstractItemModel::**removeRows**(**int** row, **int** count, const [QModelIndex]() &parent = QModelIndex())</font>
在支持此功能的模型上,从模型中删除以父项 `parent` 下给定列 `row` 开头的 `count` 行。
如果行被成功删除,返回头 `true`;否则返回 `false`。
基类的实现没有做任何事情并返回了 `false`。
如果实现自己的模型,要支持删除,则可以重新实现此函数。 另外,您可以提供自己的 `API` 来更改数据。
参见 [removeRow](#removerow)()、[removeColumns](#removecolumns)()、[insertColumns](#insertcolumns)()、[beginRemoveRows](#beginremoverows)() 和 [endRemoveRows](#endremoverows)()。
### roleNames
<font size=4>[ virtual ] [QHash]()<**int**, [QByteArray]()> QAbstractItemModel::**roleNames**() const</font>
返回模型的角色名称。
`Qt` 设置的默认角色名是:
| **Qt Role** | **QML Role Name** |
| ---- | ---- |
| [Qt::DisplayRole]() | display |
| [Qt::DecorationRole]() | decoration |
| [Qt::EditRole]() | edit |
| [Qt::ToolTipRole]() | toolTip |
| [Qt::StatusTipRole]() | statusTip |
| [Qt::WhatsThisRole]() | whatsThis |
参见 [removeRow](#removerow)()、[removeColumns](#removecolumns)()、[insertColumns](#insertcolumns)()、[beginRemoveRows](#beginremoverows)() 和 [endRemoveRows](#endremoverows)()。
该函数在 `Qt4.6` 中被引入。
参见 [setRoleNames]()()。
### rowCount
<font size=4>[ pure virtual ] **int** QAbstractItemModel::**rowCount**(const [QModelIndex]() &parent = QModelIndex()) const</font>
返回给定父节点 `parent` 下的行数。当父节点有效时,这意味着 `rowCount` 返回父节点的子节点数。
**注意:** 在实现基于表的模型时,当父节点有效时,[rowCount](#rowcount)() 应该返回 0。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [columnCount](#columncount)()。
### setData
<font size=4>[ virtual ] **bool** QAbstractItemModel::**setData**(const [QModelIndex]() &index, const [QVariant]() &value, **int** role = Qt::EditRole)</font>
将索引 `index` 处的项的角色数据设置为 `value`。
成功返回 `true`;否则返回 `false`。
如果数据被成功设置,应该发出 [dataChanged](#datachanged)() 信号。
基类的实现返回 `false`。对于可编辑的模型来说,该函数和 [data](#data)() 必须被实现。
**注意:**该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [Qt::ItemDataRole]()、[data](#data)() 和 [itemData](#itemdata)()。
### setHeaderData
<font size=4>[ virtual ] **bool** QAbstractItemModel::**setHeaderData**(**int** section, [Qt::Orientation]() orientation, const [QVariant]() &value, **int** role = Qt::EditRole)</font>
设置指定 `section`、`orientation` 和 `role` 标题的数据为 `value`。
标题数据更新完成,返回 `true`;否则返回 `false`。
在重新实现此函数时,必须显式发出 [headerDataChanged](#headerdatachanged)() 信号。
**注意:** 该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [Qt::ItemDataRole]() 和 [headerData](#headerdata)()。
### setItemData
<font size=4>[ virtual ] **bool** QAbstractItemModel::**setItemData**(const [QModelIndex]() &index, const [QMap]()<**int**, [QVariant]()> &roles)</font>
对于每个 [Qt::ItemDataRole](),将索引 `index` 处的项目的角色数据设置为角色中的关联值。
设置成功,返回 `true`;否则返回 `false`。
不在角色中的角色将不会被修改。
参见 [setData](#setdata)()、[data](#data)() 和 [itemData](#itemdata)()。
### sibling
<font size=4>[ virtual ] [QModelIndex]() QAbstractItemModel::**sibling**(**int** row, **int** column, const [QModelIndex]() &) const</font>
返回索引 `index` 项的行和列上的同级索引,如果该位置上没有同级索引,则返回无效的 [QModelIndex]()。
`sibling()` 只是一个便捷函数,它找到项的父项,并使用它来检索指定行和列中子项的索引。
可以选择性地重写此方法以进行特定于实现的优化。
**注意:**该函数可以通过元对象系统和 `QML` 调用。请参阅 [Q_INVOKABLE]()。
参见 [index](#index)()、[QModelIndex::row]()() 和 [QModelIndex::column]()()。
### sort
<font size=4>[ virtual ] **void** QAbstractItemModel::**sort**(**int** column, [Qt::SortOrder]() order = Qt::AscendingOrder)</font>
按给定顺序 `order` 按列 `column` 对模型进行排序。
基类实现不执行任何操作。
### span
<font size=4>[ virtual ] [QSize]() QAbstractItemModel::**span**(const [QModelIndex]() &index) const</font>
返回由索引 `index` 表示的项的行和列跨度。
**注意:** 目前没有使用span。
### supportedDragActions
<font size=4>[ virtual ] [Qt::DropActions]() QAbstractItemModel::**supportedDragActions**() const</font>
返回此模型中数据支持的操作。
默认实现返回 [supportedDropActions](#supporteddropactions)()。如果希望支持其他操作,请重新实现此函数。
当发生拖动时,[QAbstractItemView::startDrag]()() 使用 `supportedDragActions()` 作为默认值。
**注意:** 目前没有使用span。
参见 [setSupportedDragActions]()()、[Qt::DropActions]() 和 [在项视图中使用拖放](../../M/Model_View_Programming/Model_View_Programming.md#在项目视图中使用拖放)。
### supportedDropActions
<font size=4>[ virtual ] [Qt::DropActions]() QAbstractItemModel::**supportedDropActions**() const</font>
返回此模型支持的放置动作。
默认实现返回 [Qt::CopyAction]()。如果希望支持其他操作,请重新实现此函数。您还必须重新实现 [dropMimeData](#dropmimedata)() 函数来处理额外的操作。
该函数在 `Qt4.2` 中被引入。
参见 [dropMimeData](#dropmimedata)()、[Qt::DropActions]() 和 [在项视图中使用拖放](../../M/Model_View_Programming/Model_View_Programming.md#在项视图中使用拖放)。
================================================
FILE: Src/A/QAbstractItemView/QAbstractItemView.md
================================================
# QAbstractItemView Class
The QAbstractItemView class provides the basic functionality for item view classes. [更多内容...](QAbstractItemView.md#详细描述)
| 头文件: | #include <QAbstractItemView> |
| -------------: | :------------------------------------------------------------ |
| qmake: | QT += widgets |
| 基类: | [QAbstractScrollArea](../../A/QAbstractScrollArea/QAbstractScrollArea.md) |
| 派生类: | [QColumnView](../../C/QColumnView/QColumnView.md), [QHeaderView](../../H/QHeaderView/QHeaderView.md), [QListView](../../L/QListView/QListView.md), [QTableView](../../T/QTableView/QTableView.md), and [QTreeView](../../T/QTreeView/QTreeView.md) |
- [所有成员列表,包括继承的成员](../../A/QAbstractItemView/QAbstractItemView-members.md)
- [废弃的成员](../../A/QAbstractItemView/QAbstractItemView-obsolete.md)
## 公共成员类型
| enum | **[DragDropMode](QAbstractItemView.md#enum-qabstractitemviewdragdropmode)** { NoDragDrop, DragOnly, DropOnly, DragDrop, InternalMove } |
| -----: | :------------------------------------------------------------ |
| enum | **[EditTrigger](QAbstractItemView.md#enum-qabstractitemviewedittriggerflags-qabstractitemviewedittriggers)** { NoEditTriggers, CurrentChanged, DoubleClicked, SelectedClicked, EditKeyPressed, ..., AllEditTriggers } |
| flags | **[EditTriggers](QAbstractItemView.md#enum-qabstractitemviewedittriggerflags-qabstractitemviewedittriggers)** |
| enum | **[ScrollHint](QAbstractItemView.md#enum-qabstractitemviewscrollhint)** { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter } |
| enum | **[ScrollMode](QAbstractItemView.md#enum-qabstractitemviewscrollmode)** { ScrollPerItem, ScrollPerPixel } |
| enum | **[SelectionBehavior](QAbstractItemView.md#enum-qabstractitemviewselectionbehavior)** { SelectItems, SelectRows, SelectColumns } |
| enum | **[SelectionMode](QAbstractItemView.md#enum-qabstractitemviewselectionmode)** { SingleSelection, ContiguousSelection, ExtendedSelection, MultiSelection, NoSelection } |
## 属性
| **[alternatingRowColors](QAbstractItemView.md#alternatingrowcolors--bool)** : bool | **[horizontalScrollMode](QAbstractItemView.md#horizontalscrollmode--scrollmode)** : ScrollMode |
| :------------------------------------------------------------ | :----------------------------------------------------------- |
| **[autoScroll](QAbstractItemView.md#autoscroll--bool)** : bool | **[iconSize](QAbstractItemView.md#iconsize--qsize)** : QSize |
| **[autoScrollMargin](QAbstractItemView.md#autoscrollmargin--int)** : int | **[selectionBehavior](QAbstractItemView.md#selectionbehavior--selectionbehavior)** : SelectionBehavior |
| **[defaultDropAction](QAbstractItemView.md#defaultdropaction--qtdropaction)** : Qt::DropAction | **[selectionMode](QAbstractItemView.md#selectionmode--selectionmode)** : SelectionMode |
| **[dragDropMode](QAbstractItemView.md#dragdropmode--dragdropmode)** : DragDropMode | **[showDropIndicator](QAbstractItemView.md#showdropindicator--bool)** : bool |
| **[dragDropOverwriteMode](QAbstractItemView.md#dragdropoverwritemode--bool)** : bool | **[tabKeyNavigation](QAbstractItemView.md#tabkeynavigation--bool)** : bool |
| **[dragEnabled](QAbstractItemView.md#dragenabled--bool)** : bool | **[textElideMode](QAbstractItemView.md#textelidemode--qttextelidemode)** : Qt::TextElideMode |
| **[editTriggers](QAbstractItemView.md#edittriggers--edittriggers)** : EditTriggers | **[verticalScrollMode](QAbstractItemView.md#verticalscrollmode--scrollmode)** : ScrollMode |
## 公共成员函数
| | **[QAbstractItemView](QAbstractItemView.md#qabstractitemviewqabstractitemviewqwidget-parent--nullptr)**(QWidget **parent* = nullptr) |
| ------------------------------------: | :------------------------------------------------------------ |
| virtual | **[~QAbstractItemView](QAbstractItemView.md#virtualqabstractitemviewqabstractitemview)**() |
| bool | **[alternatingRowColors](QAbstractItemView.md#alternatingrowcolors--bool)**() const |
| int | **[autoScrollMargin](QAbstractItemView.md#autoscrollmargin--int)**() const |
| void | **[closePersistentEditor](QAbstractItemView.md#void-qabstractitemviewclosepersistenteditorconst-qmodelindex-index)**(const QModelIndex &*index*) |
| QModelIndex | **[currentIndex](QAbstractItemView.md#qmodelindex-qabstractitemviewcurrentindex-const)**() const |
| Qt::DropAction | **[defaultDropAction](QAbstractItemView.md#defaultdropaction--qtdropaction)**() const |
| QAbstractItemView::DragDropMode | **[dragDropMode](QAbstractItemView.md#dragdropmode--dragdropmode)**() const |
| bool | **[dragDropOverwriteMode](QAbstractItemView.md#dragdropoverwritemode--bool)**() const |
| bool | **[dragEnabled](QAbstractItemView.md#dragenabled--bool)**() const |
| QAbstractItemView::EditTriggers | **[editTriggers](QAbstractItemView.md#edittriggers--edittriggers)**() const |
| bool | **[hasAutoScroll](QAbstractItemView.md#autoscroll--bool)**() const |
| QAbstractItemView::ScrollMode | **[horizontalScrollMode](QAbstractItemView.md#horizontalscrollmode--scrollmode)**() const |
| QSize | **[iconSize](QAbstractItemView.md#iconsize--qsize)**() const |
| virtual QModelIndex | **[indexAt](QAbstractItemView.md#pure-virtualqmodelindex-qabstractitemviewindexatconst-qpoint-point-const)**(const QPoint &*point*) const = 0 |
| QWidget * | **[indexWidget](QAbstractItemView.md#qwidget-qabstractitemviewindexwidgetconst-qmodelindex-index-const)**(const QModelIndex &*index*) const |
| bool | **[isPersistentEditorOpen](QAbstractItemView.md#bool-qabstractitemviewispersistenteditoropenconst-qmodelindex-index-const)**(const QModelIndex &*index*) const |
| QAbstractItemDelegate * | **[itemDelegate](QAbstractItemView.md#qabstractitemdelegate-qabstractitemviewitemdelegate-const)**() const |
| QAbstractItemDelegate * | **[itemDelegate](QAbstractItemView.md#qabstractitemdelegate-qabstractitemviewitemdelegateconst-qmodelindex-index-const)**(const QModelIndex &*index*) const |
| QAbstractItemDelegate * | **[itemDelegateForColumn](QAbstractItemView.md#qabstractitemdelegate-qabstractitemviewitemdelegateforcolumnint-column-const)**(int *column*) const |
| QAbstractItemDelegate * | **[itemDelegateForRow](QAbstractItemView.md#qabstractitemdelegate-qabstractitemviewitemdelegateforrowint-row-const)**(int *row*) const |
| virtual void | **[keyboardSearch](QAbstractItemView.md#virtualvoid-qabstractitemviewkeyboardsearchconst-qstring-search)**(const QString &*search*) |
| QAbstractItemModel * | **[model](QAbstractItemView.md#qabstractitemmodel-qabstractitemviewmodel-const)**() const |
| void | **[openPersistentEditor](QAbstractItemView.md#void-qabstractitemviewopenpersistenteditorconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[resetHorizontalScrollMode](QAbstractItemView.md#horizontalscrollmode--scrollmode)**() |
| void | **[resetVerticalScrollMode](QAbstractItemView.md#verticalscrollmode--scrollmode)**() |
| QModelIndex | **[rootIndex](QAbstractItemView.md#qmodelindex-qabstractitemviewrootindex-const)**() const |
| virtual void | **[scrollTo](QAbstractItemView.md#pure-virtualvoid-qabstractitemviewscrolltoconst-qmodelindex-index-qabstractitemviewscrollhint-hint--ensurevisible)**(const QModelIndex &*index*, QAbstractItemView::ScrollHint *hint* = EnsureVisible) = 0 |
| QAbstractItemView::SelectionBehavior | **[selectionBehavior](QAbstractItemView.md#selectionbehavior--selectionbehavior)**() const |
| QAbstractItemView::SelectionMode | **[selectionMode](QAbstractItemView.md#selectionmode--selectionmode)**() const |
| QItemSelectionModel * | **[selectionModel](QAbstractItemView.md#qitemselectionmodel-qabstractitemviewselectionmodel-const)**() const |
| void | **[setAlternatingRowColors](QAbstractItemView.md#alternatingrowcolors--bool)**(bool *enable*) |
| void | **[setAutoScroll](QAbstractItemView.md#autoscroll--bool)**(bool *enable*) |
| void | **[setAutoScrollMargin](QAbstractItemView.md#autoscrollmargin--int)**(int *margin*) |
| void | **[setDefaultDropAction](QAbstractItemView.md#defaultdropaction--qtdropaction)**(Qt::DropAction *dropAction*) |
| void | **[setDragDropMode](QAbstractItemView.md#dragdropmode--dragdropmode)**(QAbstractItemView::DragDropMode *behavior*) |
| void | **[setDragDropOverwriteMode](QAbstractItemView.md#dragdropoverwritemode--bool)**(bool *overwrite*) |
| void | **[setDragEnabled](QAbstractItemView.md#dragenabled--bool)**(bool *enable*) |
| void | **[setDropIndicatorShown](QAbstractItemView.md#showdropindicator--bool)**(bool *enable*) |
| void | **[setEditTriggers](QAbstractItemView.md#edittriggers--edittriggers)**(QAbstractItemView::EditTriggers *triggers*) |
| void | **[setHorizontalScrollMode](QAbstractItemView.md#horizontalscrollmode--scrollmode)**(QAbstractItemView::ScrollMode *mode*) |
| void | **[setIconSize](QAbstractItemView.md#iconsize--qsize)**(const QSize &*size*) |
| void | **[setIndexWidget](QAbstractItemView.md#void-qabstractitemviewsetindexwidgetconst-qmodelindex-index-qwidget-widget)**(const QModelIndex &*index*, QWidget **widget*) |
| void | **[setItemDelegate](QAbstractItemView.md#void-qabstractitemviewsetitemdelegateqabstractitemdelegate-delegate)**(QAbstractItemDelegate **delegate*) |
| void | **[setItemDelegateForColumn](QAbstractItemView.md#void-qabstractitemviewsetitemdelegateforcolumnint-column-qabstractitemdelegate-delegate)**(int *column*, QAbstractItemDelegate **delegate*) |
| void | **[setItemDelegateForRow](QAbstractItemView.md#void-qabstractitemviewsetitemdelegateforrowint-row-qabstractitemdelegate-delegate)**(int *row*, QAbstractItemDelegate **delegate*) |
| virtual void | **[setModel](QAbstractItemView.md#virtualvoid-qabstractitemviewsetmodelqabstractitemmodel-model)**(QAbstractItemModel **model*) |
| void | **[setSelectionBehavior](QAbstractItemView.md#selectionbehavior--selectionbehavior)**(QAbstractItemView::SelectionBehavior *behavior*) |
| void | **[setSelectionMode](QAbstractItemView.md#selectionmode--selectionmode)**(QAbstractItemView::SelectionMode *mode*) |
| virtual void | **[setSelectionModel](QAbstractItemView.md#virtualvoid-qabstractitemviewsetselectionmodelqitemselectionmodel-selectionmodel)**(QItemSelectionModel **selectionModel*) |
| void | **[setTabKeyNavigation](QAbstractItemView.md#tabkeynavigation--bool)**(bool *enable*) |
| void | **[setTextElideMode](QAbstractItemView.md#textelidemode--qttextelidemode)**(Qt::TextElideMode *mode*) |
| void | **[setVerticalScrollMode](QAbstractItemView.md#verticalscrollmode--scrollmode)**(QAbstractItemView::ScrollMode *mode*) |
| bool | **[showDropIndicator](QAbstractItemView.md#showdropindicator--bool)**() const |
| virtual int | **[sizeHintForColumn](QAbstractItemView.md#virtualint-qabstractitemviewsizehintforcolumnint-column-const)**(int *column*) const |
| QSize | **[sizeHintForIndex](QAbstractItemView.md#qsize-qabstractitemviewsizehintforindexconst-qmodelindex-index-const)**(const QModelIndex &*index*) const |
| virtual int | **[sizeHintForRow](QAbstractItemView.md#virtualint-qabstractitemviewsizehintforrowint-row-const)**(int *row*) const |
| bool | **[tabKeyNavigation](QAbstractItemView.md#tabkeynavigation--bool)**() const |
| Qt::TextElideMode | **[textElideMode](QAbstractItemView.md#textelidemode--qttextelidemode)**() const |
| QAbstractItemView::ScrollMode | **[verticalScrollMode](QAbstractItemView.md#verticalscrollmode--scrollmode)**() const |
| virtual QRect | **[visualRect](QAbstractItemView.md#pure-virtualqrect-qabstractitemviewvisualrectconst-qmodelindex-index-const)**(const QModelIndex &*index*) const = 0 |
## 重写公共成员函数
| virtual QVariant | **[inputMethodQuery](QAbstractItemView.md#override-virtualqvariant-qabstractitemviewinputmethodqueryqtinputmethodquery-query-const)**(Qt::InputMethodQuery *query*) const override |
| ----------------: | :------------------------------------------------------------ |
| | |
## 公共槽函数
| void | **[clearSelection](QAbstractItemView.md#slotvoid-qabstractitemviewclearselection)**() |
| ------------: | :------------------------------------------------------------ |
| void | **[edit](QAbstractItemView.md#slotvoid-qabstractitemvieweditconst-qmodelindex-index)**(const QModelIndex &*index*) |
| virtual void | **[reset](QAbstractItemView.md#virtual-slotvoid-qabstractitemviewreset)**() |
| void | **[scrollToBottom](QAbstractItemView.md#slotvoid-qabstractitemviewscrolltobottom)**() |
| void | **[scrollToTop](QAbstractItemView.md#slotvoid-qabstractitemviewscrolltotop)**() |
| virtual void | **[selectAll](QAbstractItemView.md#virtual-slotvoid-qabstractitemviewselectall)**() |
| void | **[setCurrentIndex](QAbstractItemView.md#slotvoid-qabstractitemviewsetcurrentindexconst-qmodelindex-index)**(const QModelIndex &*index*) |
| virtual void | **[setRootIndex](QAbstractItemView.md#virtual-slotvoid-qabstractitemviewsetrootindexconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[update](QAbstractItemView.md#slotvoid-qabstractitemviewupdateconst-qmodelindex-index)**(const QModelIndex &*index*) |
## 信号
| void | **[activated](QAbstractItemView.md#signalvoid-qabstractitemviewactivatedconst-qmodelindex-index)**(const QModelIndex &*index*) |
| ----: | :------------------------------------------------------------ |
| void | **[clicked](QAbstractItemView.md#signalvoid-qabstractitemviewclickedconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[doubleClicked](QAbstractItemView.md#signalvoid-qabstractitemviewdoubleclickedconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[entered](QAbstractItemView.md#signalvoid-qabstractitemviewenteredconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[iconSizeChanged](QAbstractItemView.md#iconsize--qsize)**(const QSize &*size*) |
| void | **[pressed](QAbstractItemView.md#signalvoid-qabstractitemviewpressedconst-qmodelindex-index)**(const QModelIndex &*index*) |
| void | **[viewportEntered](QAbstractItemView.md#signalvoid-qabstractitemviewviewportentered)**() |
## 保护成员类型
| enum | **[CursorAction](QAbstractItemView.md#enum-qabstractitemviewcursoraction)** { MoveUp, MoveDown, MoveLeft, MoveRight, MoveHome, ..., MovePrevious } |
| ----: | :------------------------------------------------------------ |
| enum | **[DropIndicatorPosition](QAbstractItemView.md#enum-qabstractitemviewdropindicatorposition)** { OnItem, AboveItem, BelowItem, OnViewport } |
| enum | **[State](QAbstractItemView.md#enum-qabstractitemviewstate)** { NoState, DraggingState, DragSelectingState, EditingState, ExpandingState, ..., AnimatingState } |
## 保护成员函数
| QPoint | **[dirtyRegionOffset](QAbstractItemView.md#protectedqpoint-qabstractitemviewdirtyregionoffset-const)**() const |
| -------------------------------------------: | :------------------------------------------------------------ |
| QAbstractItemView::DropIndicatorPosition | **[dropIndicatorPosition](QAbstractItemView.md#protectedqabstractitemviewdropindicatorposition-qabstractitemviewdropindicatorposition-const)**() const |
| virtual bool | **[edit](QAbstractItemView.md#virtual-protectedbool-qabstractitemvieweditconst-qmodelindex-index-qabstractitemviewedittrigger-trigger-qevent-event)**(const QModelIndex &*index*, QAbstractItemView::EditTrigger *trigger*, QEvent **event*) |
| void | **[executeDelayedItemsLayout](QAbstractItemView.md#protectedvoid-qabstractitemviewexecutedelayeditemslayout)**() |
| virtual int | **[horizontalOffset](QAbstractItemView.md#pure-virtual-protectedint-qabstractitemviewhorizontaloffset-const)**() const = 0 |
| virtual bool | **[isIndexHidden](QAbstractItemView.md#pure-virtual-protectedbool-qabstractitemviewisindexhiddenconst-qmodelindex-index-const)**(const QModelIndex &*index*) const = 0 |
| virtual QModelIndex | **[moveCursor](QAbstractItemView.md#pure-virtual-protectedqmodelindex-qabstractitemviewmovecursorqabstractitemviewcursoraction-cursoraction-qtkeyboardmodifiers-modifiers)**(QAbstractItemView::CursorAction *cursorAction*, Qt::KeyboardModifiers *modifiers*) = 0 |
| void | **[scheduleDelayedItemsLayout](QAbstractItemView.md#protectedvoid-qabstractitemviewscheduledelayeditemslayout)**() |
| void | **[scrollDirtyRegion](QAbstractItemView.md#protectedvoid-qabstractitemviewscrolldirtyregionint-dx-int-dy)**(int *dx*, int *dy*) |
| virtual QModelIndexList | **[selectedIndexes](QAbstractItemView.md#virtual-protectedqmodelindexlist-qabstractitemviewselectedindexes-const)**() const |
| virtual QItemSelectionModel::SelectionFlags | **[selectionCommand](QAbstractItemView.md#virtual-protectedqitemselectionmodelselectionflags-qabstractitemviewselectioncommandconst-qmodelindex-index-const-qevent-event--nullptr-const)**(const QModelIndex &*index*, const QEvent **event* = nullptr) const |
| void | **[setDirtyRegion](QAbstractItemView.md#protectedvoid-qabstractitemviewsetdirtyregionconst-qregion-region)**(const QRegion &*region*) |
| virtual void | **[setSelection](QAbstractItemView.md#pure-virtual-protectedvoid-qabstractitemviewsetselectionconst-qrect-rect-qitemselectionmodelselectionflags-flags)**(const QRect &*rect*, QItemSelectionModel::SelectionFlags *flags*) = 0 |
| void | **[setState](QAbstractItemView.md#protectedvoid-qabstractitemviewsetstateqabstractitemviewstate-state)**(QAbstractItemView::State *state*) |
| virtual void | **[startDrag](QAbstractItemView.md#virtual-protectedvoid-qabstractitemviewstartdragqtdropactions-supportedactions)**(Qt::DropActions *supportedActions*) |
| QAbstractItemView::State | **[state](QAbstractItemView.md#protectedqabstractitemviewstate-qabstractitemviewstate-const)**() const |
| virtual int | **[verticalOffset](QAbstractItemView.md#pure-virtual-protectedint-qabstractitemviewverticaloffset-const)**() const = 0 |
| virtual QStyleOptionViewItem | **[viewOptions](QAbstractItemView.md#virtual-protectedqstyleoptionviewitem-qabstractitemviewviewoptions-const)**() const |
| virtual QRegion | **[visualRegionForSelection](QAbstractItemView.md#pure-virtual-protectedqregion-qabstractitemviewvisualregionforselectionconst-qitemselection-selection-const)**(const QItemSelection &*selection*) const = 0 |
## 重写保护成员函数
| virtual void | **[dragEnterEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewdragentereventqdragenterevent-event)**(QDragEnterEvent **event*) override |
| -------------: | :------------------------------------------------------------ |
| virtual void | **[dragLeaveEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewdragleaveeventqdragleaveevent-event)**(QDragLeaveEvent **event*) override |
| virtual void | **[dragMoveEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewdragmoveeventqdragmoveevent-event)**(QDragMoveEvent **event*) override |
| virtual void | **[dropEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewdropeventqdropevent-event)**(QDropEvent **event*) override |
| virtual bool | **[event](QAbstractItemView.md#override-virtual-protectedbool-qabstractitemvieweventqevent-event)**(QEvent **event*) override |
| virtual bool | **[eventFilter](QAbstractItemView.md#override-virtual-protectedbool-qabstractitemvieweventfilterqobject-object-qevent-event)**(QObject **object*, QEvent **event*) override |
| virtual void | **[focusInEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewfocusineventqfocusevent-event)**(QFocusEvent **event*) override |
| virtual bool | **[focusNextPrevChild](QAbstractItemView.md#override-virtual-protectedbool-qabstractitemviewfocusnextprevchildbool-next)**(bool *next*) override |
| virtual void | **[focusOutEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewfocusouteventqfocusevent-event)**(QFocusEvent **event*) override |
| virtual void | **[inputMethodEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewinputmethodeventqinputmethodevent-event)**(QInputMethodEvent **event*) override |
| virtual void | **[keyPressEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewkeypresseventqkeyevent-event)**(QKeyEvent **event*) override |
| virtual void | **[mouseDoubleClickEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewmousedoubleclickeventqmouseevent-event)**(QMouseEvent **event*) override |
| virtual void | **[mouseMoveEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewmousemoveeventqmouseevent-event)**(QMouseEvent **event*) override |
| virtual void | **[mousePressEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewmousepresseventqmouseevent-event)**(QMouseEvent **event*) override |
| virtual void | **[mouseReleaseEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewmousereleaseeventqmouseevent-event)**(QMouseEvent **event*) override |
| virtual void | **[resizeEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewresizeeventqresizeevent-event)**(QResizeEvent **event*) override |
| virtual void | **[timerEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewtimereventqtimerevent-event)**(QTimerEvent **event*) override |
| virtual bool | **[viewportEvent](QAbstractItemView.md#override-virtual-protectedbool-qabstractitemviewviewporteventqevent-event)**(QEvent **event*) override |
| virtual QSize | **[viewportSizeHint](QAbstractItemView.md#override-virtual-protectedqsize-qabstractitemviewviewportsizehint-const)**() const override |
## 保护槽函数
| virtual void | **[closeEditor](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewcloseeditorqwidget-editor-qabstractitemdelegateendedithint-hint)**(QWidget **editor*, QAbstractItemDelegate::EndEditHint *hint*) |
| ------------: | :------------------------------------------------------------ |
| virtual void | **[commitData](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewcommitdataqwidget-editor)**(QWidget **editor*) |
| virtual void | **[currentChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewcurrentchangedconst-qmodelindex-current-const-qmodelindex-previous)**(const QModelIndex &*current*, const QModelIndex &*previous*) |
| virtual void | **[dataChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewdatachangedconst-qmodelindex-topleft-const-qmodelindex-bottomright-const-qvectorint-roles--qvectorint)**(const QModelIndex &*topLeft*, const QModelIndex &*bottomRight*, const QVector<int> &*roles* = QVector<int>()) |
| virtual void | **[editorDestroyed](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemvieweditordestroyedqobject-editor)**(QObject **editor*) |
| virtual void | **[rowsAboutToBeRemoved](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewrowsabouttoberemovedconst-qmodelindex-parent-int-start-int-end)**(const QModelIndex &*parent*, int *start*, int *end*) |
| virtual void | **[rowsInserted](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewrowsinsertedconst-qmodelindex-parent-int-start-int-end)**(const QModelIndex &*parent*, int *start*, int *end*) |
| virtual void | **[selectionChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewselectionchangedconst-qitemselection-selected-const-qitemselection-deselected)**(const QItemSelection &*selected*, const QItemSelection &*deselected*) |
| virtual void | **[updateGeometries](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewupdategeometries)**() |
## 详细描述
QAbstractItemView class is the base class for every standard view that uses a [QAbstractItemModel](../../A/QAbstractItemModel/QAbstractItemModel.md). QAbstractItemView is an abstract class and cannot itself be instantiated. It provides a standard interface for interoperating with models through the signals and slots mechanism, enabling subclasses to be kept up-to-date with changes to their models. This class provides standard support for keyboard and mouse navigation, viewport scrolling, item editing, and selections. The keyboard navigation implements this functionality:
| Keys | Functionality |
| --------------- | ---------------------------------------------------------- |
| Arrow keys | Changes the current item and selects it. |
| Ctrl+Arrow keys | Changes the current item but does not select it. |
| Shift+Arrow keys | Changes the current item and selects it. The previously selected item(s) is not deselected. |
| Ctrl+Space | Toggles selection of the current item. |
| Tab/Backtab | Changes the current item to the next/previous item. |
| Home/End | Selects the first/last item in the model. |
| Page up/Page down | Scrolls the rows shown up/down by the number of visible rows in the view. |
| Ctrl+A | Selects all items in the model. |
Note that the above table assumes that the [selection mode](QAbstractItemView.md#selectionmode--selectionmode) allows the operations. For instance, you cannot select items if the selection mode is [QAbstractItemView::NoSelection](QAbstractItemView.md#enum-qabstractitemviewselectionmode).
The QAbstractItemView class is one of the [Model/View Classes](../../M/Model_View_Programming/Model_View_Programming.md#模型/视图类) and is part of Qt's [model/view framework](../../M/Model_View_Programming/Model_View_Programming.md).
The view classes that inherit QAbstractItemView only need to implement their own view-specific functionality, such as drawing items, returning the geometry of items, finding items, etc.
QAbstractItemView provides common slots such as [edit](QAbstractItemView.md#slotvoid-qabstractitemvieweditconst-qmodelindex-index)() and [setCurrentIndex](QAbstractItemView.md#slotvoid-qabstractitemviewsetcurrentindexconst-qmodelindex-index)(). Many protected slots are also provided, including [dataChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewdatachangedconst-qmodelindex-topleft-const-qmodelindex-bottomright-const-qvectorint-roles--qvectorint)(), [rowsInserted](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewrowsinsertedconst-qmodelindex-parent-int-start-int-end)(), [rowsAboutToBeRemoved](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewrowsabouttoberemovedconst-qmodelindex-parent-int-start-int-end)(), [selectionChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewselectionchangedconst-qitemselection-selected-const-qitemselection-deselected)(), and [currentChanged](QAbstractItemView.md#virtual-protected-slotvoid-qabstractitemviewcurrentchangedconst-qmodelindex-current-const-qmodelindex-previous)().
The root item is returned by [rootIndex](QAbstractItemView.md#qmodelindex-qabstractitemviewrootindex-const)(), and the current item by [currentIndex](QAbstractItemView.md#qmodelindex-qabstractitemviewcurrentindex-const)(). To make sure that an item is visible use [scrollTo](QAbstractItemView.md#pure-virtualvoid-qabstractitemviewscrolltoconst-qmodelindex-index-qabstractitemviewscrollhint-hint--ensurevisible)().
Some of QAbstractItemView's functions are concerned with scrolling, for example [setHorizontalScrollMode](QAbstractItemView.md#horizontalscrollmode--scrollmode)() and [setVerticalScrollMode](QAbstractItemView.md#verticalscrollmode--scrollmode)(). To set the range of the scroll bars, you can, for example, reimplement the view's [resizeEvent](QAbstractItemView.md#override-virtual-protectedvoid-qabstractitemviewresizeeventqresizeevent-event)() function:
```c++
void MyView::resizeEvent(QResizeEvent *event) {
horizontalScrollBar()->setRange(0, realWidth - width());
...
}
```
Note that the range is not updated until the widget is shown.
Several other functions are concerned with selection control; for example [setSelectionMode](QAbstractItemView.md#selectionmode--selectionmode)(), and [setSelectionBehavior](QAbstractItemView.md#selectionbehavior--selectionbehavior)(). This class provides a default selection model to work with ([selectionModel](QAbstractItemView.md#qitemselectionmodel-qabstractitemviewselectionmodel-const)()), but this can be replaced by using [setSelectionModel](QAbstractItemView.md#virtualvoid-qabstractitemviewsetselection
gitextract_hmtc6ynp/ ├── .github/ │ └── ISSUE_TEMPLATE/ │ └── ----.md ├── Book/ │ ├── book/ │ │ └── .nojekyll │ ├── book.toml │ └── src/ │ ├── BookInfo.md │ └── SUMMARY.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Comparison_Table.md ├── Grammar_Tips.md ├── LICENSE ├── Logo/ │ └── README.md ├── README.md ├── Src/ │ ├── A/ │ │ ├── API_Design_Principles/ │ │ │ └── API_Design_Principles.md │ │ ├── QAbstractAnimation/ │ │ │ └── QAbstractAnimation.md │ │ ├── QAbstractAudioDeviceInfo/ │ │ │ └── QAbstractAudioDeviceInfo.md │ │ ├── QAbstractAudioInput/ │ │ │ └── QAbstractAudioInput.md │ │ ├── QAbstractAudioOutput/ │ │ │ └── QAbstractAudioOutput.md │ │ ├── QAbstractAxis/ │ │ │ └── QAbstractAxis.md │ │ ├── QAbstractBarSeries/ │ │ │ └── QAbstractBarSeries.md │ │ ├── QAbstractItemModel/ │ │ │ └── QAbstractItemModel.md │ │ ├── QAbstractItemView/ │ │ │ └── QAbstractItemView.md │ │ ├── QAbstractSocket/ │ │ │ └── QAbstractSocket.md │ │ └── QAction/ │ │ └── QAction.md │ ├── B/ │ │ └── Best_Practice_Guides/ │ │ └── Best_Practice_Guides.md │ ├── C/ │ │ ├── Container_Classes/ │ │ │ └── Container_Classes.md │ │ ├── QCheckBox/ │ │ │ └── QCheckBox.md │ │ ├── QComboBox/ │ │ │ └── QComboBox.md │ │ └── QCoreApplication/ │ │ └── QCoreApplication.md │ ├── D/ │ │ └── QDate/ │ │ └── QDate.md │ ├── F/ │ │ ├── QFile/ │ │ │ └── QFile.md │ │ └── QFileInfo/ │ │ ├── QFileInfo.md │ │ ├── qfileinfo-members.md │ │ └── qfileinfo-obsolete.md │ ├── G/ │ │ ├── QGenericArgument/ │ │ │ └── QGenericArgument.md │ │ ├── QGenericReturnArgument/ │ │ │ └── QGenericReturnArgument.md │ │ └── QtGlobal/ │ │ └── QtGlobal.md │ ├── H/ │ │ ├── QHash/ │ │ │ ├── QHash-const-iterator.md │ │ │ ├── QHash-iterator.md │ │ │ ├── QHash-key-iterator.md │ │ │ └── QHash.md │ │ └── QHashIterator/ │ │ └── QHashIterator.md │ ├── I/ │ │ └── QIODevice/ │ │ └── QIODevice.md │ ├── J/ │ │ ├── QJsonArray/ │ │ │ └── QJsonArray.md │ │ ├── QJsonDocument/ │ │ │ └── QJsonDocument.md │ │ ├── QJsonObject/ │ │ │ └── QJsonObject.md │ │ ├── QJsonParseError/ │ │ │ └── QJsonParseError.md │ │ └── QJsonValue/ │ │ └── QJsonValue.md │ ├── K/ │ │ └── QKeyValueIterator/ │ │ └── QKeyValueIterator.md │ ├── L/ │ │ ├── QLabel/ │ │ │ └── QLabel.md │ │ ├── QLibrary/ │ │ │ └── QLibrary.md │ │ └── QList/ │ │ ├── QList.md │ │ ├── QListIterator.md │ │ ├── QList_Const_Iterator.md │ │ ├── QList_Iterator.md │ │ └── QMutableListIterator.md │ ├── M/ │ │ ├── Model_View_Programming/ │ │ │ └── Model_View_Programming.md │ │ ├── Model_View_Tutorial/ │ │ │ └── Model_View_Tutorial.md │ │ ├── Multithreading_Technologies_in_Qt/ │ │ │ └── Multithreading_Technologies_in_Qt.md │ │ ├── QMainWindow/ │ │ │ └── QMainWindow.md │ │ ├── QMap/ │ │ │ ├── QMap-const-iterator.md │ │ │ ├── QMap-iterator.md │ │ │ ├── QMap-key-iterator.md │ │ │ └── QMap.md │ │ ├── QMapIterator/ │ │ │ └── QMapIterator.md │ │ ├── QMetaClassInfo/ │ │ │ └── QMetaClassInfo.md │ │ ├── QMetaMethod/ │ │ │ └── QMetaMethod.md │ │ ├── QMetaObject/ │ │ │ ├── QMetaObject.md │ │ │ └── QMetaObject_Connection.md │ │ ├── QMetaProperty/ │ │ │ └── QMetaProperty.md │ │ ├── QMetaType/ │ │ │ └── QMetaType.md │ │ ├── QMultiHash/ │ │ │ └── QMultiHash.md │ │ ├── QMultiMap/ │ │ │ └── QMultiMap.md │ │ ├── QMutableHashIterator/ │ │ │ └── QMutableHashIterator.md │ │ ├── QMutableMapIterator/ │ │ │ └── QMutableMapIterator.md │ │ ├── QMutex/ │ │ │ └── QMutex.md │ │ ├── QMutexLocker/ │ │ │ └── QMutexLocker.md │ │ ├── The_Meta-Object_System/ │ │ │ └── The_Meta-Object_System.md │ │ ├── Using_the_Meta-Object_Compiler_moc/ │ │ │ └── Using_the_Meta-Object_Compiler_moc.md │ │ └── Why_Does_Qt_Use_Moc_for_Signals_and_Slots/ │ │ └── Why_Does_Qt_Use_Moc_for_Signals_and_Slots.md │ ├── O/ │ │ ├── QObject/ │ │ │ └── QObject.md │ │ └── QOpenGLShaderProgram/ │ │ └── QOpenGLShaderProgram.md │ ├── P/ │ │ ├── QPaintDevice/ │ │ │ └── QPaintDevice.md │ │ ├── QPaintEngine/ │ │ │ └── QPaintEngine.md │ │ ├── QPainter/ │ │ │ └── QPainter.md │ │ ├── QPluginLoader/ │ │ │ └── QPluginLoader.md │ │ ├── QtPlugin/ │ │ │ └── QtPlugin.md │ │ └── The_Property_System/ │ │ └── The_Property_System.md │ ├── Q/ │ │ ├── Qt_Namespace/ │ │ │ └── Qt_Namespace.md │ │ └── Qt_Overviews/ │ │ └── Qt_Overviews.md │ ├── R/ │ │ ├── QReadLocker/ │ │ │ └── QReadLocker.md │ │ ├── QReadWriteLock/ │ │ │ └── QReadWriteLock.md │ │ ├── QRecursiveMutex/ │ │ │ └── QRecursiveMutex.md │ │ ├── Reentrancy_and_Thread-Safety/ │ │ │ └── Reentrancy_and_Thread-Safety.md │ │ ├── Resource_Compiler_rcc/ │ │ │ └── Resource_Compiler_rcc.md │ │ └── The_Qt_Resource_System/ │ │ └── The_Qt_Resource_System.md │ ├── S/ │ │ ├── QSctpServer/ │ │ │ └── QSctpServer.md │ │ ├── QSctpSocket/ │ │ │ └── QSctpSocket.md │ │ ├── QSemaphore/ │ │ │ └── QSemaphore.md │ │ ├── QSerialPort/ │ │ │ └── QSerialPort.md │ │ ├── QSerialPortInfo/ │ │ │ └── QSerialPortInfo.md │ │ ├── QSql/ │ │ │ └── QSql.md │ │ ├── QSqlDatabase/ │ │ │ └── QSqlDatabase.md │ │ ├── QSsl/ │ │ │ └── QSsl.md │ │ ├── QSslCertificate/ │ │ │ └── QSslCertificate.md │ │ ├── QSslCertificateExtension/ │ │ │ └── QSslCertificateExtension.md │ │ ├── QSslCertificate_Obsolete/ │ │ │ └── QSslCertificate_Obsolete.md │ │ ├── QSslCipher/ │ │ │ └── QSslCipher.md │ │ ├── QSslConfiguration/ │ │ │ └── QSslConfiguration.md │ │ ├── QSslError/ │ │ │ └── QSslError.md │ │ ├── QSslKey/ │ │ │ └── QSslKey.md │ │ ├── QSslSocket/ │ │ │ └── QSslSocket.md │ │ ├── QSslSocket_Obsolete/ │ │ │ └── QSslSocket_Obsolete.md │ │ ├── QStyledItemDelegate/ │ │ │ └── QStyledItemDelegate.md │ │ ├── Signals_and_Slots/ │ │ │ └── Signals_and_Slots.md │ │ └── Synchronizing_Threads/ │ │ └── Synchronizing_Threads.md │ ├── T/ │ │ ├── QTcpServer/ │ │ │ └── QTcpServer.md │ │ ├── QTcpSocket/ │ │ │ └── QTcpSocket.md │ │ ├── QText2DEntity/ │ │ │ └── QText2DEntity.md │ │ ├── QTimeLine/ │ │ │ └── QTimeLine.md │ │ ├── QTimer/ │ │ │ └── QTimer.md │ │ └── QTransform/ │ │ └── QTransform.md │ ├── U/ │ │ └── QUdpSocket/ │ │ └── QUdpSocket.md │ ├── V/ │ │ └── QVariant/ │ │ └── QVariant.md │ ├── W/ │ │ ├── QWaitCondition/ │ │ │ └── QWaitCondition.md │ │ ├── QWebEngineHistory/ │ │ │ └── QWebEngineHistory.md │ │ ├── QWebEngineHistoryItem/ │ │ │ └── QWebEngineHistoryItem.md │ │ ├── QWebEngineView/ │ │ │ └── QWebEngineView.md │ │ ├── QWriteLocker/ │ │ │ └── QWriteLocker.md │ │ └── WebEngine/ │ │ └── QWebEngineView.md │ └── X/ │ └── QX11Info/ │ └── QX11Info.md ├── Template.md └── completeness_tracking.md
Condensed preview — 132 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,638K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/----.md",
"chars": 535,
"preview": "---\nname: 翻译需求\nabout: 有需要优先翻译的文档,向社区提出翻译需求\ntitle: ''\nlabels: 翻译需求\nassignees: ''\n\n---\n\n**需求文档**\n\n请贴出需要翻译的文档链接(基于 [doc.qt."
},
{
"path": "Book/book/.nojekyll",
"chars": 71,
"preview": "This file makes sure that Github Pages doesn't process mdBook's output."
},
{
"path": "Book/book.toml",
"chars": 101,
"preview": "[book]\nauthors = [\"zhangpengfei1\"]\nlanguage = \"en\"\nmultilingual = false\nsrc = \"src\"\ntitle = \"Qt中文文档\"\n"
},
{
"path": "Book/src/BookInfo.md",
"chars": 196,
"preview": "# Qt中文文档\n\n本网站github链接\n\n[QtDocumentCN](https://github.com/QtDocumentCN/QtDocumentCN)\n\ngitee镜像链接\n[gitee-QtDocument](https:"
},
{
"path": "Book/src/SUMMARY.md",
"chars": 5691,
"preview": "# Summary\n\n- [简介](./BookInfo.md)\n\t- [A]()\n\t\t- [QAbstractAnimation](./Src/A/QAbstractAnimation/QAbstractAnimation.md)\n\t\t-"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 1019,
"preview": "\n# 参与者公约\n\n## 我们的承诺\n\n为建设开放友好的环境,我们贡献者和维护者承诺:不论年龄、体型、身体健全与否、民族、性征、性别认同与表征、经验水平、教育程度、社会地位、国籍、相貌、种族、信仰、性取向,我们项目和社区的参与者皆免于骚扰。"
},
{
"path": "CONTRIBUTING.md",
"chars": 3541,
"preview": "# 贡献指南\n\n## 提交说明\n\n各种提交代码之前一定要\n\n```shell\ngit pull --rebase\n```\n\n\n\n## 目录/文件管理\n\n为方便快速填充内容,以及便于跨文档引用,文档按首字母排序,从A-Z共12个根文件夹。\n\n"
},
{
"path": "Comparison_Table.md",
"chars": 1986,
"preview": "# 词汇对照表\n\n这里是文档翻译的词汇对照表,详情请见[贡献指南](https://github.com/QtDocumentCN/QtDocumentCN/blob/master/CONTRIBUTING.md)。 \n\n| 英 "
},
{
"path": "Grammar_Tips.md",
"chars": 4745,
"preview": "# 语法小贴士\n\n本文件用于总结翻译英文技术文档时,如何尽可能实现信达雅。\n\n\n\n## 翻译原则\n\n1. 尽量使用书面语,避免口语化:\n 1. 但避免用力过猛,令句子明显诘屈聱牙;\n 2. 尽量避免出现任何人称代词。\n2. 避免过于"
},
{
"path": "LICENSE",
"chars": 9226,
"preview": "署名—非商业性使用—相同方式共享 4.0 协议国际版\n\n========================================================================\n\n知识共享组织(“Creative C"
},
{
"path": "Logo/README.md",
"chars": 1692,
"preview": "# Logo 设计\n\n方形图标:\n\n\n."
},
{
"path": "Src/A/API_Design_Principles/API_Design_Principles.md",
"chars": 27768,
"preview": "# API 设计规范\n\n> 译者注:\n>\n> 本文不来自于 Qt 文档,而是来自于 Qt Wiki:[API_Design_Principles](https://wiki.qt.io/API_Design_Principles)\n>\n> "
},
{
"path": "Src/A/QAbstractAnimation/QAbstractAnimation.md",
"chars": 18402,
"preview": "[TOC]\n# QAbstractAnimation 类\nQAbstractAnimation 是所有的动画相关的基类。\n\nQAbstractAnimation 定义了所有动画类相关的基础功能,通过继承该类,您可以实现动画的其它功能,或者添"
},
{
"path": "Src/A/QAbstractAudioDeviceInfo/QAbstractAudioDeviceInfo.md",
"chars": 2124,
"preview": "[TOC]\n# **QAbstractAudioDeviceInfo类**\n\n----------\n## **QAbstractAudioDeviceInfo是音频后端的基类**\n\n| 属性| 方法|\n| ------: |:------|"
},
{
"path": "Src/A/QAbstractAudioInput/QAbstractAudioInput.md",
"chars": 4484,
"preview": "[TOC]\n# **QAbstractAudioInput类**\n\n----------\n\n\n## **QAbstractAudioInput类为QAudioInput类提供了访问音频设备的方法。(通过插件的形式)**\n\n| 属性| 方法|"
},
{
"path": "Src/A/QAbstractAudioOutput/QAbstractAudioOutput.md",
"chars": 4620,
"preview": "[TOC]\n#**QAbstractAudioOutput类**\n\n----------\n\n## **QAbstractAudioOutput类是音频后端的基类**\n\n| 属性 | 方法|\n|------:|:------|\n|头文件包"
},
{
"path": "Src/A/QAbstractAxis/QAbstractAxis.md",
"chars": 18234,
"preview": "[TOC]\n# **QAbstractAxis**\n\n----------\n\n## **QAbstractAxis类是用于专门处理坐标轴的类**\n\n| 属性 | 方法|\n|------:|:------|\n|头文件:|` #inc"
},
{
"path": "Src/A/QAbstractBarSeries/QAbstractBarSeries.md",
"chars": 2860,
"preview": "[TOC]\n# **QAbstractBarSeries**\n \n----------\n \n## **QAbstractBarSeries是所有柱状图/条形图系列的基类**\n\n \n| 属性 | 方法|\n|------:|:------|"
},
{
"path": "Src/A/QAbstractItemModel/QAbstractItemModel.md",
"chars": 59198,
"preview": "# QAbstractItemModel 类\n\nQAbstractItemModel类为项模型类提供了抽象接口。[更多...]()\n\n| 属性 | 方法 |\n| ---- | ---- |\n| 头文件 | `#include <QAbstr"
},
{
"path": "Src/A/QAbstractItemView/QAbstractItemView.md",
"chars": 105131,
"preview": "# QAbstractItemView Class\n\nThe QAbstractItemView class provides the basic functionality for item view classes. [更多内容...]"
},
{
"path": "Src/A/QAbstractSocket/QAbstractSocket.md",
"chars": 51921,
"preview": "[TOC]\n\n\n\n# QAbstractSocket Class\n\nQAbstractSocket 类是Qt中 Socket 通信类的基类,被 [QTcpSocket](../../T/QTcpSocket/QTcpSocket.md) 和"
},
{
"path": "Src/A/QAction/QAction.md",
"chars": 37,
"preview": "Reserved by yangle until 2020-08-31.\n"
},
{
"path": "Src/B/Best_Practice_Guides/Best_Practice_Guides.md",
"chars": 3197,
"preview": "# 最佳实践指南\r\n\r\n这些文档为使用 Qt 解决特定的技术问题提供指南和最佳实践,可用以指导开发者,如何尽可能使用 Qt 技术创建具有卓越的可用性和软件设计的应用程序。\r\n\r\n| 页面 "
},
{
"path": "Src/C/Container_Classes/Container_Classes.md",
"chars": 29242,
"preview": "# 容器\n\n## 引言\n\nQt 提供了一系列基于模板的通用容器类,可以用于存储指定类型的元素。例如,如果你需要一个可动态调整大小的 [QString](../../S/QString/QString.md) 数组,那么你可以使用 [QVec"
},
{
"path": "Src/C/QCheckBox/QCheckBox.md",
"chars": 36,
"preview": "Reserved by leytou until 2020-07-31\n"
},
{
"path": "Src/C/QComboBox/QComboBox.md",
"chars": 36,
"preview": "Reserved by leytou until 2020-07-31\n"
},
{
"path": "Src/C/QCoreApplication/QCoreApplication.md",
"chars": 26098,
"preview": "Reserved by froser until 2020-09-15\n\n[TOC]\n\n# QCoreApplication 类\n\nQCoreApplication类为没有UI的Qt程序提供了一个事件循环。\n\n| 属性 | 方法 "
},
{
"path": "Src/D/QDate/QDate.md",
"chars": 28230,
"preview": "[TOC]\r\n\r\n# QDate Class\r\n\r\n\r\n| 属性 | 方法 |\r\n| ------ | ------------------ |\r\n| 头文件 | #include `<QDate>` |\r\n"
},
{
"path": "Src/F/QFile/QFile.md",
"chars": 25438,
"preview": "# QFile Class\r\n\r\nQFile 类提供读写文件的接口。 \r\n\r\n| 属性 | 方法 |\r\n| ------------- | --------------------------------------------------"
},
{
"path": "Src/F/QFileInfo/QFileInfo.md",
"chars": 37345,
"preview": "# QFileInfo 类\r\n\r\nQFileInfo 类用于系统无关的文件信息。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\r\n\r\n|属性|方法|\r\n|----:|:----|\r\n|头文件"
},
{
"path": "Src/F/QFileInfo/qfileinfo-members.md",
"chars": 5488,
"preview": "# QFileInfo 成员函数完整列表\r\n\r\n这是 [QFileInfo](https://doc.qt.io/qt-5/qfileinfo.html) 的成员函数的完整列表,包括继承的函数。\r\n\r\n|返回类型|函数名|\r\n|----:|"
},
{
"path": "Src/F/QFileInfo/qfileinfo-obsolete.md",
"chars": 1349,
"preview": "# QFileInfo 废弃的成员函数\r\n\r\n[QFileInfo](https://doc.qt.io/qt-5/qfileinfo.html) 类的以下成员函数已废弃。提供它们是为了使旧的源代码正常工作。 我们强烈建议不要在新代码中使用"
},
{
"path": "Src/G/QGenericArgument/QGenericArgument.md",
"chars": 1723,
"preview": "# QGenericArgument 类\n\n`QGenericArgument` 类是用于序列化参数的内部辅助类。[更多信息...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\n\n| 属性 | 内容 "
},
{
"path": "Src/G/QGenericReturnArgument/QGenericReturnArgument.md",
"chars": 1270,
"preview": "# QGenericReturnArgument 类\n\n`QGenericReturnArgument` 类是用于序列化返回值的内部辅助类。[更多信息...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\n\n"
},
{
"path": "Src/G/QtGlobal/QtGlobal.md",
"chars": 42,
"preview": "Reserved by ZgblKylin until 2020-07-31\r\n\r\n"
},
{
"path": "Src/H/QHash/QHash-const-iterator.md",
"chars": 6099,
"preview": "# const_iterator 类\n\nclass [QHash](../../H/QHash/QHash.md)::const_iterator\n\n[QHash::const_iterator](../../H/QHash/QHash-c"
},
{
"path": "Src/H/QHash/QHash-iterator.md",
"chars": 7261,
"preview": "# iterator 类\n\nclass [QHash](../../H/QHash/QHash.md)::iterator\n\n[QHash::iterator](../../H/QHash/QHash-iterator.md) 为 [QHa"
},
{
"path": "Src/H/QHash/QHash-key-iterator.md",
"chars": 4576,
"preview": "# key_iterator 类\n\nclass [QHash](https://doc.qt.io/qt-5/qhash.html#qhash)::key_iterator\n\n[QHash::key_iterator](../../H/QH"
},
{
"path": "Src/H/QHash/QHash.md",
"chars": 51327,
"preview": "# QHash 类\n\ntemplate <typename Key, typename T> class QHash\n\nQHash 类是一种模板类,提供基于哈希表的字典类结构。[更多内容...](QHash.md#详细描述)\n\n| 头文件:"
},
{
"path": "Src/H/QHashIterator/QHashIterator.md",
"chars": 6028,
"preview": "# QHashIterator Class\n\ntemplate <typename Key, typename T> class QHashIterator\n\nQHashIterator 类为 [QHash](../../H/QHash/Q"
},
{
"path": "Src/I/QIODevice/QIODevice.md",
"chars": 64,
"preview": "[TOC]\n\n\n\n# QIODevice Class\n\nReserved by Skykey until 2020-07-31\n"
},
{
"path": "Src/J/QJsonArray/QJsonArray.md",
"chars": 39,
"preview": "reserved by hqwx2018 until 2020-08-15 \n"
},
{
"path": "Src/J/QJsonDocument/QJsonDocument.md",
"chars": 39,
"preview": "reserved by hqwx2018 until 2020-08-15 \n"
},
{
"path": "Src/J/QJsonObject/QJsonObject.md",
"chars": 39,
"preview": "reserved by hqwx2018 until 2020-08-15 \n"
},
{
"path": "Src/J/QJsonParseError/QJsonParseError.md",
"chars": 3693,
"preview": "[TOC]\n\n\n\n# QJsonParseError Struct\n\nQJsonParseError类用于在JSON解析期间报告错误。\n\n| 属性 | 方法 |\n| "
},
{
"path": "Src/J/QJsonValue/QJsonValue.md",
"chars": 40,
"preview": "reserved by hqwx2018 until 2020-08-15 \n"
},
{
"path": "Src/K/QKeyValueIterator/QKeyValueIterator.md",
"chars": 5303,
"preview": "# QKeyValueIterator 类\n\ntemplate <typename Key, typename T, typename Iterator> class QKeyValueIterator\n\n关联容器的键值对类型的迭代器。[更"
},
{
"path": "Src/L/QLabel/QLabel.md",
"chars": 36,
"preview": "Reserved by leytou until 2020-07-31\n"
},
{
"path": "Src/L/QLibrary/QLibrary.md",
"chars": 14304,
"preview": "# QLibrary Class\r\n\r\nQlibrary用于运行时加载库。\r\n\r\n| 属性 | 内容 |\r\n| ------- | ---------------------------------------------- |\r\n| 头文"
},
{
"path": "Src/L/QList/QList.md",
"chars": 55600,
"preview": "# QList Class\n\n`template <typename T> class QList`\n\nQList 类是一个用于提供列表支持的模板类。[更多...](QList.md#details)\n\n| | "
},
{
"path": "Src/L/QList/QListIterator.md",
"chars": 0,
"preview": ""
},
{
"path": "Src/L/QList/QList_Const_Iterator.md",
"chars": 11241,
"preview": "# const_iterator 类\n\n类 [QList](../../L/QList/QList.md)::const_iterator\n\n[QList::const_iterator](QList_Const_Iterator.md) "
},
{
"path": "Src/L/QList/QList_Iterator.md",
"chars": 11180,
"preview": "# 迭代器类\n\n类 [QList](../../L/QList/QList.md)::iterator\n\n[QList::iterator](QList_Iterator.md) 类为 [QList](../../L/QList/QList"
},
{
"path": "Src/L/QList/QMutableListIterator.md",
"chars": 0,
"preview": ""
},
{
"path": "Src/M/Model_View_Programming/Model_View_Programming.md",
"chars": 53524,
"preview": "# 模型/视图 编程\n\n## 模型/视图编程简介 \n`Qt` 中包含了一系列的项目视图类,他们使用了模型/视图架构来管理数据和显示之间的关系。此架构的功能分离特征给开发人员在自定义项目的呈现形式时带来了很大的灵活性,并提供标准的模型接口,以"
},
{
"path": "Src/M/Model_View_Tutorial/Model_View_Tutorial.md",
"chars": 24925,
"preview": "# 模型视图教程\n\n每个 `UI` 开发人员都应该了解模型视图编程,本教程的目的是让您轻松理解有关模型视图的相关知识。\n\n表格,列表和树部件是 `GUI` 中经常使用的组件。这些部件可以通过两种不同的方式访问其数据。传统方式是,这些部件包含"
},
{
"path": "Src/M/Multithreading_Technologies_in_Qt/Multithreading_Technologies_in_Qt.md",
"chars": 5122,
"preview": "# Qt 中的多线程技术\n\nQt 提供一系列的类与函数来处理多线程。Qt 开发者们可以使用下面四种方法来实现多线程应用。\n\n\n\n## QThread: 低级 API 与可选的事件循环\n\n作为 Qt 进行线程控制的基石,每一个 QThread"
},
{
"path": "Src/M/QMainWindow/QMainWindow.md",
"chars": 32432,
"preview": "# QMainWindow 类\r\n\r\nQMainWindow 类用于创建主程序窗口。 [更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\r\n\r\n|属性|方法|\r\n|----:|:----|\r\n|"
},
{
"path": "Src/M/QMap/QMap-const-iterator.md",
"chars": 8651,
"preview": "# const_iterator 类\n\nclass [QMap](../../M/QMap/QMap.md)::const_iterator\n\n[QMap::const_iterator](../../M/QMap/QMap-const-i"
},
{
"path": "Src/M/QMap/QMap-iterator.md",
"chars": 9151,
"preview": "# iterator 类\n\nclass [QMap](../../M/QMap/QMap.md)::iterator\n\n[QMap::iterator](../../M/QMap/QMap-iterator.md) 类为 [QMap](.."
},
{
"path": "Src/M/QMap/QMap-key-iterator.md",
"chars": 4886,
"preview": "# key_iterator 类\n\nclass [QMap](../../M/QMap/QMap.md)::key_iterator\n\n[QMap::key_iterator](../../M/QMap/QMap-key-iterator."
},
{
"path": "Src/M/QMap/QMap.md",
"chars": 35760,
"preview": "# QMap 类\n\ntemplate <typename Key, typename T> class QMap\n\nQMap 类是一种模板类,提供基于红黑树的字典类结构。[更多内容...](QMap.md#详细描述)\n\n| 头文件: "
},
{
"path": "Src/M/QMapIterator/QMapIterator.md",
"chars": 9776,
"preview": "# QMapIterator 类\n\ntemplate <typename Key, typename T> class QMapIterator\n\nQMapIterator 类为 [QMap](../../M/QMap/QMap.md) 和"
},
{
"path": "Src/M/QMetaClassInfo/QMetaClassInfo.md",
"chars": 1433,
"preview": "# QMetaClassInfo 类\n\nQMetaClassInfo 类提供了某个类的附加信息。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\n\n| 属性 | 内容 "
},
{
"path": "Src/M/QMetaMethod/QMetaMethod.md",
"chars": 27642,
"preview": "# QMetaMethod 类\r\n\r\nQMetaMethod 类提供了对应一个成员函数的元数据。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\r\n\r\n| 属性 | 内容 "
},
{
"path": "Src/M/QMetaObject/QMetaObject.md",
"chars": 37396,
"preview": "# QMetaObject 结构体\r\n\r\nQMetaObject 类包含了 Qt 对象的元信息。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)。\r\n\r\n| 属性 | 内容 "
},
{
"path": "Src/M/QMetaObject/QMetaObject_Connection.md",
"chars": 2290,
"preview": "# Connection 类\n\n[QMetaObject](../../M/QMetaObject/QMetaObject.md)::Connection 类。\n\n\n\n## 公共成员函数\n\n| 返回类型 | 函数 "
},
{
"path": "Src/M/QMetaProperty/QMetaProperty.md",
"chars": 13332,
"preview": "# QMetaProperty 类\n\nQMetaProperty 类提供了对应一条属性的元数据。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)\n\n| 属性 | 内容 "
},
{
"path": "Src/M/QMetaType/QMetaType.md",
"chars": 46303,
"preview": "# QMetaType 类\r\n\r\nQMetaType 类管理元对象系统中的注名类型。[更多内容...](#%E8%AF%A6%E7%BB%86%E6%8F%8F%E8%BF%B0)。\r\n\r\n| 属性 | 内容 "
},
{
"path": "Src/M/QMultiHash/QMultiHash.md",
"chars": 11818,
"preview": "# QMultiHash 类\n\ntemplate <typename Key, typename T> class QMultiHash\n\nQMultiHash 类是一个便利的 [QHash](../../H/QHash/QHash.md)"
},
{
"path": "Src/M/QMultiMap/QMultiMap.md",
"chars": 11154,
"preview": "# QMultiMap Class\n\ntemplate <typename Key, typename T> class QMultiMap\n\nQMultiMap 类是一个便利的 [QMap](../../M/QMap/QMap.md) 派"
},
{
"path": "Src/M/QMutableHashIterator/QMutableHashIterator.md",
"chars": 8597,
"preview": "# QMutableHashIterator Class\n\ntemplate <typename Key, typename T> class QMutableHashIterator\n\nQMutableHashIterator 类为 [Q"
},
{
"path": "Src/M/QMutableMapIterator/QMutableMapIterator.md",
"chars": 13462,
"preview": "# QMutableMapIterator 类\n\ntemplate <typename Key, typename T> class QMutableMapIterator\n\nQMutableMapIterator 类为 [QMap](.."
},
{
"path": "Src/M/QMutex/QMutex.md",
"chars": 6436,
"preview": "\n# QMutex\n\n  QMutex类提供线程间的访问序列化。[更多...](#详细描述)\n|属性|内容|\n|-|-|\n|头文件|`#include<QMutex>`|\n|qmake|`QT += core`|\n|子类"
},
{
"path": "Src/M/QMutexLocker/QMutexLocker.md",
"chars": 4283,
"preview": "\n\n# QMutexLocker\n\n  `QMutexLocker` 是一个工具类,它能非常方便地将互斥量锁定以及解锁。[更多内容...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include <QM"
},
{
"path": "Src/M/The_Meta-Object_System/The_Meta-Object_System.md",
"chars": 3981,
"preview": "# 元对象系统\n\nQt 的元对象系统提供了对象间通信的信号槽机制、运行时类型信息,以及动态属性系统。\n\n元对象系统基于以下三者:\n\n1. [QObject](../../O/QObject/QObject.md) 类,提供了便于利用元对象系"
},
{
"path": "Src/M/Using_the_Meta-Object_Compiler_moc/Using_the_Meta-Object_Compiler_moc.md",
"chars": 8291,
"preview": "# 使用元对象编译器(moc)\r\n\r\n\r\n\r\n\r\n\r\n元对象编译器 `moc` 是用于处理 [Qt 的 C++ 扩展](../The_Meta-Object_System/The_Meta-Object_System.md) 的程序。\r\n\r"
},
{
"path": "Src/M/Why_Does_Qt_Use_Moc_for_Signals_and_Slots/Why_Does_Qt_Use_Moc_for_Signals_and_Slots.md",
"chars": 4086,
"preview": "# 为何 Qt 使用 Moc 实现信号槽?\r\n\r\n模板是 C++ 的内建机制,可以允许编译器基于传递的参数类型,在编译期生成代码。因此,框架编写者很喜欢使用模板,而我们也的确在 Qt 的许多地方使用了高阶的模板特性。然而,模板有限制的:有的"
},
{
"path": "Src/O/QObject/QObject.md",
"chars": 42,
"preview": "Reserved by ZgblKylin until 2020-07-31\r\n\r\n"
},
{
"path": "Src/O/QOpenGLShaderProgram/QOpenGLShaderProgram.md",
"chars": 96405,
"preview": "Reserved by kongdehui until 2022-07-31.\n\n# QOpenGLShaderProgram 类\n\nQOpenGLShaderProgram类允许链接和使用OpenGL着色器程序。 [More...](ht"
},
{
"path": "Src/P/QPaintDevice/QPaintDevice.md",
"chars": 40,
"preview": "Reserved by CryFeiFei until 2020-08-31.\n"
},
{
"path": "Src/P/QPaintEngine/QPaintEngine.md",
"chars": 12585,
"preview": "\n# QPaintEngine Class\n\nQPaintEngine类为[QPainter](../../P/QPainter/QPainter.md)提供了如何在指定绘图设备上(译者注:一般为QPaintDevice的派生)绘制的一些抽"
},
{
"path": "Src/P/QPainter/QPainter.md",
"chars": 41,
"preview": "\nReserved by CryFeiFei until 2020-08-31.\n"
},
{
"path": "Src/P/QPluginLoader/QPluginLoader.md",
"chars": 9776,
"preview": "# QPluginLoader Class\n\nQPluginLoader 在运行时加载插件.\n\n| 属性 | 方法 |\n| --------- "
},
{
"path": "Src/P/QtPlugin/QtPlugin.md",
"chars": 2688,
"preview": "# \\<QtPlugin\\> - 定义插件\n\nQtPlugin 头文件定义用于定义插件的宏。\n\n| 属性 | 方法 |\n| -----: | :--------------------- |\n| 头文"
},
{
"path": "Src/P/The_Property_System/The_Property_System.md",
"chars": 42,
"preview": "Reserved by ZgblKylin until 2020-07-31\r\n\r\n"
},
{
"path": "Src/Q/Qt_Namespace/Qt_Namespace.md",
"chars": 39,
"preview": "Reserved by ZgblKylin until 2020-07-31\n"
},
{
"path": "Src/Q/Qt_Overviews/Qt_Overviews.md",
"chars": 1054,
"preview": "# Qt概述\r\n\r\nQt 提供了覆盖广泛领域的各类技术。以下话题关键功能领域,并且可以用作学习如何充分利用 Qt 的起点。\r\n\r\n- [开发工具](../../D/Development_Tools/Development_Tools.md"
},
{
"path": "Src/R/QReadLocker/QReadLocker.md",
"chars": 2192,
"preview": "\n# QReadLocker\n\n  `QReadLocker` 是工具类,它简化了对读写锁,读访问的的锁定和解锁。[更多...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include<QReadLoc"
},
{
"path": "Src/R/QReadWriteLock/QReadWriteLock.md",
"chars": 5829,
"preview": "\n# QReadWriteLock\n\n  `QReadWriteLock` 类提供读写锁定。[更多...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include<QReadWriteLock>`|\n|"
},
{
"path": "Src/R/QRecursiveMutex/QRecursiveMutex.md",
"chars": 1426,
"preview": "\n# QRcursiveMutex\n\n  QRcursiveMutex类提供线程间的访问序列化。[更多...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include<QRcursiveMutex>`|"
},
{
"path": "Src/R/Reentrancy_and_Thread-Safety/Reentrancy_and_Thread-Safety.md",
"chars": 0,
"preview": ""
},
{
"path": "Src/R/Resource_Compiler_rcc/Resource_Compiler_rcc.md",
"chars": 2143,
"preview": "# 资源编译器(rcc)\r\n\r\n`rcc` 工具用于在编译期将资源数据集成至 Qt 应用。它基于 Qt 资源文件(`.qrc`) 来生成包含资源数据的 C++ 源文件。\r\n\r\n使用方式:\r\n\r\n```bash\r\nrcc [选项列表] <输"
},
{
"path": "Src/R/The_Qt_Resource_System/The_Qt_Resource_System.md",
"chars": 5903,
"preview": "# Qt 资源系统\n\nQt 资源系统是一套平台独立的机制,用于将二进制文件存储至应用程序的可执行文件中。这在您的应用始终依赖一组特定文件(如图标、翻译文件等),并且不想承担丢失这些文件的风险时,会非常有用。\n\n资源系统基于 [qmake]("
},
{
"path": "Src/S/QSctpServer/QSctpServer.md",
"chars": 5454,
"preview": "[TOC]\n\n\n\n# QSctpServer Class\n\nQSctpServer 提供了一个基于 QSCTP 协议的服务器。\n\n| 属性 | 方法 "
},
{
"path": "Src/S/QSctpSocket/QSctpSocket.md",
"chars": 7972,
"preview": "[TOC]\r\n\r\n\r\n\r\n# QSctpSocket Class\r\n\r\nQSctpSocket 类提供了一个 SCTP 类型的套接字。\r\n\r\n| 属性 | 方法 "
},
{
"path": "Src/S/QSemaphore/QSemaphore.md",
"chars": 4613,
"preview": "\n\n\n# QSemaphore\n\n  QSemaphore类提供了一个通用的信号量。[更多内容...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include <QSemaphore>`|\n|`qmak"
},
{
"path": "Src/S/QSerialPort/QSerialPort.md",
"chars": 44269,
"preview": "# QSerialPort 类\r\n\r\nQSerialPort 类用于访问串口。 [更多内容...](https://doc.qt.io/qt-5/qserialport.html#details)\r\n\r\n|属性|方法|\r\n|----:|:-"
},
{
"path": "Src/S/QSerialPortInfo/QSerialPortInfo.md",
"chars": 7846,
"preview": "# QSerialPortInfo 类\r\n\r\nQSerialPortInfo 类提供了系统中现有串口的相关信息。 [更多内容...](https://doc.qt.io/qt-5/qserialportinfo.html#details)\r"
},
{
"path": "Src/S/QSql/QSql.md",
"chars": 2236,
"preview": "# QSql 命名空间\n\nQSql 命名空间 里的 各种名样的标识符,已经被运用在 Qt SQL 各个模块中。[更多](https://doc.qt.io/qt-5/qsql.html#details)\n\n\n| 属性 | 方法 "
},
{
"path": "Src/S/QSqlDatabase/QSqlDatabase.md",
"chars": 37520,
"preview": "\n# **QSqlDatabase 类**\nQSqlDatabase 类 用于处理数据库的连接\n\n| 属性 | 方法 |\n|"
},
{
"path": "Src/S/QSsl/QSsl.md",
"chars": 7673,
"preview": "[TOC]\n\n\n\n# QSsl Namespace\n\nQSsl 命名空间为所有的 SSL 类声明了通用的枚举类型。\n\n| 属性 | 方法 |\n| -------- | ----------------- |"
},
{
"path": "Src/S/QSslCertificate/QSslCertificate.md",
"chars": 19473,
"preview": "[TOC]\n\n\n\n# QSslCertificate Class\n\nQSslCertificate 类为 X509 证书提供了便捷的 API 集成。\n\n| 属性 | 方法 |\n| ----"
},
{
"path": "Src/S/QSslCertificateExtension/QSslCertificateExtension.md",
"chars": 5199,
"preview": "[TOC]\n\n\n\n# QSslCertificateExtension Class\n\nQSslCertificateExtension 类为使用 X509证书扩展提供了 API 支持。\n\n| 属性 | 方法 "
},
{
"path": "Src/S/QSslCertificate_Obsolete/QSslCertificate_Obsolete.md",
"chars": 3914,
"preview": "[TOC]\n\n\n\n# QSslCertificate Obsolete Members\n\n以下的 [QSslCertificate](../QSslCertificate/QSslCertificate.md) 类成员都已废弃。为了保证旧代"
},
{
"path": "Src/S/QSslCipher/QSslCipher.md",
"chars": 5925,
"preview": "[TOC]\n\n\n\n# QSslCipher Class\n\nQSslCipher 类提供了 SSL 密钥的支持。\n\n| 属性 | 方法 |\n| ------ | -------------------"
},
{
"path": "Src/S/QSslConfiguration/QSslConfiguration.md",
"chars": 71,
"preview": "[TOC]\n\n\n\n# QSslConfiguration Class\n\nReserved by Skykey until 2020-07-31"
},
{
"path": "Src/S/QSslError/QSslError.md",
"chars": 7367,
"preview": "[TOC]\n\n\n\n# QSslError Class\n\nQSslError 类提供了一些关于 SSl 错误的相关信息与操作。\n\n| 属性 | 方法 |\n| ------ | -------------"
},
{
"path": "Src/S/QSslKey/QSslKey.md",
"chars": 6973,
"preview": "[TOC]\n\n\n\n# QSslKey Class\n\nQSslKey 类为私钥、公钥提供了相应的接口。\n\n| 属性 | 方法 |\n| ------ | -------------------- |\n| 头文"
},
{
"path": "Src/S/QSslSocket/QSslSocket.md",
"chars": 46249,
"preview": "[TOC]\r\n\r\n# QSslSocket Class\r\n\r\nQSslSocket 类为客户端和服务端提供了一个 SSL 加密的套接字。\r\n\r\n| 属性 | 方法 |\r\n| ------ | ---"
},
{
"path": "Src/S/QSslSocket_Obsolete/QSslSocket_Obsolete.md",
"chars": 27726,
"preview": "[TOC]\n\n\n\n# Obsolete Members for QSslSocket\n\n这里是 QSslSocket 类中已废弃的成员函数。为了保证旧代码仍能运行,Qt 官方保留了这些废弃的函数。但是 Qt 官方强烈建议不要在新的代码中使用"
},
{
"path": "Src/S/QStyledItemDelegate/QStyledItemDelegate.md",
"chars": 2768,
"preview": "[toc]\n# QStyledItemDelegate\n\n`QStyledItemDelegate ` 类为模型(model)中的数据项提供显示和编辑功能。\n\n| 属性 | 方法 "
},
{
"path": "Src/S/Signals_and_Slots/Signals_and_Slots.md",
"chars": 11768,
"preview": "# 信号与槽\r\n\r\n信号(Signals)和槽(Slots)被用于在 Qt 对象之间通信。信号槽机制是 Qt 的核心特性,同时也可能是与其他框架的类似特性区别最大的一部分。信号槽使得 Qt 的[元对象系统](../../M/The_Meta"
},
{
"path": "Src/S/Synchronizing_Threads/Synchronizing_Threads.md",
"chars": 2193,
"preview": "# 同步线程\n\n尽管线程的初衷是让代码并行运行,仍然有许多时候,线程必须停下来等待其他线程。例如,若有两个线程尝试同时写入同一个变量,则结果是不确定的。让线程强制等待另外线程,这样的机制被称为*互斥*,是一种保护共享资源(如数据)的常用技术"
},
{
"path": "Src/T/QTcpServer/QTcpServer.md",
"chars": 14777,
"preview": "[TOC]\r\n\r\n\r\n\r\n# QTcpServer Class\r\n\r\nQTcpServer 类提供了一个基于 TCP 协议的服务器。\r\n\r\n| 属性 | 方法 "
},
{
"path": "Src/T/QTcpSocket/QTcpSocket.md",
"chars": 2045,
"preview": "[TOC]\n\n\n\n# QTcpSocket Class\n\nQTcpSocket 提供了一个 TCP 类型的套接字。\n\n| 属性 | 方法 "
},
{
"path": "Src/T/QText2DEntity/QText2DEntity.md",
"chars": 3225,
"preview": "# QText2DEntity Class\nclass [Qt3DExtras](Qt3DExtras.md#)::QText2DEntity\n\nQText2DEntity 允许在 3D 空间中创建 2D 文本。 [更多的...](QTex"
},
{
"path": "Src/T/QTimeLine/QTimeLine.md",
"chars": 17138,
"preview": "# QTimeLine Class\n\nQTimeLine类提供用于控制动画的时间线。\n\n| 头文件: | #include <QTimeLine> |\n| ------- | ------"
},
{
"path": "Src/T/QTimer/QTimer.md",
"chars": 17633,
"preview": "[TOC]\n\n\n\n# QTimer Class\n\nQTimer提供了重复和信号槽的定时器。\n\n| 属性 | 方法 |\n| -------- | -----------"
},
{
"path": "Src/T/QTransform/QTransform.md",
"chars": 8877,
"preview": "这里是文档翻译的模板,详情请见[贡献指南](https://github.com/QtDocumentCN/QtDocumentCN/blob/master/CONTRIBUTING.md)。\n\n文档翻译的名词对照表可见[对照表](Comp"
},
{
"path": "Src/U/QUdpSocket/QUdpSocket.md",
"chars": 13249,
"preview": "[TOC]\n\n\n\n# QUdpSocket Class\n\nQUdpSocket 类提供了 UDP 类型的套接字。\n\n| 属性 | 方法 "
},
{
"path": "Src/V/QVariant/QVariant.md",
"chars": 42,
"preview": "Reserved by ZgblKylin until 2020-07-31\r\n\r\n"
},
{
"path": "Src/W/QWaitCondition/QWaitCondition.md",
"chars": 5461,
"preview": "\n# QWaitCondition\n\n  `QWaitCondition` 提供一个用于同步线程的条件变量。[更多...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include<QWaitCondit"
},
{
"path": "Src/W/QWebEngineHistory/QWebEngineHistory.md",
"chars": 7304,
"preview": "[TOC]\n\n\n\n# QWebEngineHistory class\n\nQWebEngineHistory类表示Web引擎页面的历史记录。\n\n| 属性 | 方法 |\n| -----"
},
{
"path": "Src/W/QWebEngineHistoryItem/QWebEngineHistoryItem.md",
"chars": 3490,
"preview": "[TOC]\n\n\n\n# QWebEngineHistoryItem Class\n\nQWebEngineHistoryItem类表示Web引擎页面历史记录中的一项。\n\n| 属性 | 方法 "
},
{
"path": "Src/W/QWebEngineView/QWebEngineView.md",
"chars": 18456,
"preview": "[TOC]\n\n# QWebEngineView Class\n\nQWebEngineView类提供了一个widget, 被使用去查看和编辑web元素。\n\n| 属性 | 方法 |\n| ---"
},
{
"path": "Src/W/QWriteLocker/QWriteLocker.md",
"chars": 2228,
"preview": "\n# QWriteLocker\n\n  `QWriteLocker` 是工具类,它简化了对读写锁,写访问的的锁定和解锁。[更多...](#详细描述)\n\n|属性|内容|\n|-|-|\n|头文件|`#include<QWrite"
},
{
"path": "Src/W/WebEngine/QWebEngineView.md",
"chars": 38,
"preview": "reserved by hqwx2018 until 2020-07-31\n"
},
{
"path": "Src/X/QX11Info/QX11Info.md",
"chars": 4747,
"preview": "\n\n# **QX11Info**\n\n **提供有关X11相关的相关配置信息(就是linux下的x11相关的配置信息)**\n----------\n \n| 属性 | 方法|\n|------:|:------|\n|头文件:| `#includ"
},
{
"path": "Template.md",
"chars": 6889,
"preview": "这里是文档翻译的模板,详情请见[贡献指南](https://github.com/QtDocumentCN/QtDocumentCN/blob/master/CONTRIBUTING.md)。\n\n文档翻译的名词对照表可见[对照表](Comp"
},
{
"path": "completeness_tracking.md",
"chars": 15471,
"preview": "# 完成度追踪表\n\n此表格用于追踪待完成或有待进一步维护的文档状态,详见[贡献指南](CONTRIBUTING.md)。\n\n翻译进度说明:\n\n- 编写中:参与者提交占位文件,或正在编辑中,尚未完成第一版提交。此阶段文档内容变动较大,为避免冲"
}
]
About this extraction
This page contains the full source code of the QtDocumentCN/QtDocumentCN GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 132 files (1.5 MB), approximately 557.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.