本页内容

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
operator QJniObject() const

静态公共成员

auto fromContainer(Container &&container)

受保护函数

QJniArrayBase()
QJniArrayBase(const QJniArrayBase &other)
QJniArrayBase(QJniArrayBase &&other)
~QJniArrayBase()
void swap(QJniArrayBase &other)
QJniArrayBase &operator=(QJniArrayBase &&other)
QJniArrayBase &operator=(const QJniArrayBase &other)

详细说明

成员类型文档

[alias] QJniArrayBase::size_type

一个 32 位整数。

成员函数文档

[noexcept protected default] QJniArrayBase::QJniArrayBase()

默认——构造一个QJniArrayBase 实例。

[explicit noexcept protected default] QJniArrayBase::QJniArrayBase(const QJniArrayBase &other)

复制并构造一个QJniArrayBase 实例。

[explicit noexcept protected default] QJniArrayBase::QJniArrayBase(QJniArrayBase &&other)

通过Move操作构造一个QJniArrayBase 实例。

[noexcept protected default] QJniArrayBase::~QJniArrayBase()

销毁QJniArrayBase 的实例。

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

创建一个用于存储container 中数据的Java数组,并返回一个封装该数组的QJniArray 实例。

约束

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

所构建的QJniArray 的特化形式取决于container 的值类型。对于Container<T> (例如QList<T> ),其通常为QJniArray<T> ,但有以下例外:

容器特化
QByteArrayQJniArray<jbyte>
QStringListQJniArray<jstring>
容器::value_type特化
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 互换。此操作速度极快,且绝不会失败。

QJniArrayBase::operator QJniObject() const

返回一个QJniObject ,该对象封装了与该QJniArray 实例相同的jobject 。

[noexcept protected default] QJniArrayBase &QJniArrayBase::operator=(QJniArrayBase &&other)

将other 通过“移动赋值”操作赋值给此QJniArrayBase 实例。

[noexcept protected default] QJniArrayBase &QJniArrayBase::operator=(const QJniArrayBase &other)

将other 复制并赋值给此QJniArrayBase 实例。

© 2026 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.