QJniArrayBase Class

QJniArrayBase 类为QJniArray 提供了通用的、与类型无关的 API。更多

头文件: #include <QJniArrayBase>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Qt 6.8
继承:

QJniArray

公共类型

公共函数

bool isEmpty() const
bool isValid() const
T object() const
QJniArrayBase::size_type size() const
QJniObject operator QJniObject() const

静态公共成员

auto fromContainer(Container &&container)

保护函数

void swap(QJniArrayBase &other)

详细说明

成员类型文档

[alias] QJniArrayBase::size_type

一个 32 位整数。

成员函数文档

[static] template <typename Container, QJniArrayBase::if_compatible_source_container<Container> = true> auto QJniArrayBase::fromContainer(Container &&container)

创建一个 Java 数组,其中包含container 中的数据,并返回一个封装该数组的QJniArray 实例。

限制条件

只有当Container 是一个存储JNI type 或等价 C++ 类型元素的容器,并提供一个前向迭代器时,才会参与重载解析。

构建的QJniArray 的特殊化取决于container 的值类型。对于Container<T> (例如QList<T> ),通常是QJniArray<T> ,但以下情况除外:

容器特殊化
QByteArrayQJniArray<jbyte
QStringListQJniArray<j字符串
容器::值类型特殊化
QJniObjectQJniArray<jobject>(项目

另请参阅 QJniArray::toContainer().

bool QJniArrayBase::isEmpty() const

如果数组大小为 0,则返回true ;否则返回false

invalid 数组总是空的。

isValid(),size()

bool QJniArrayBase::isValid() const

返回QJniArray 对象是否封装了有效的 `jobject`。对于无效的QJniArray 实例,object() 返回nullptr 。对无效对象进行遍历是安全的(begin() 返回值与 end()相同),对无效数组调用toContainer() 将返回空容器。

另请参见 QJniObject::isValid()、object() 和QJniArray::toContainer()。

template <typename T = jobject> T QJniArrayBase::object() const

返回QJniArray 持有的 T 类型对象,它可以是JNI Object Types 中的一个。

QJniArrayBase::size_type QJniArrayBase::size() const

返回数组的大小。

[noexcept protected] void QJniArrayBase::swap(QJniArrayBase &other)

将此数组对象与other 互换。该操作速度非常快,而且从未出现过故障。

QJniObject QJniArrayBase::operator QJniObject() const

返回与此QJniArray 实例相同的QJniObject 封装jobject

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