没志青年
发布于 2025-07-29 / 19 阅读
0

QT 数据类型

数据对齐 rightJustified

C++ 中的数据类型 Qt 中都能使用

新增数据类型

类型转换 qobject_cast

运行时类型转换运算符,用于在 ​​QObject 继承体系​​ 中安全地进行 ​​向下转型,即父转子:

QWidget *editor

QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);

要求类必须继承自 ​​QObject​​,并且有 ​​Q_OBJECT 宏​。

比 C++ 的 dynamic_cast 更高效更安全,转换失败不会导致未定义行为,而是返回 nullptr。

字符串

QString

QByteArray

QT 数据结构

QList

QStringList

QSet

QMap

QHash

QVector

QStack

QQueue