On this page

QJniArrayBase Class

The QJniArrayBase class provides common, type-independent APIs for QJniArray. More...

Header: #include <QJniArrayBase>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.8
Inherited By:

QJniArray

Public Types

Public Functions

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

Static Public Members

auto fromContainer(Container &&container)

Protected Functions

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

Detailed Description

Member Type Documentation

[alias] QJniArrayBase::size_type

A 32 bit integer.

Member Function Documentation

[noexcept protected default] QJniArrayBase::QJniArrayBase()

Default-constructs an instance of QJniArrayBase.

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

Copy-constructs an instance of QJniArrayBase.

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

Move-constructs an instance of QJniArrayBase.

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

Destroys the instance of QJniArrayBase.

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

Creates a Java array holding the data in container, and returns a QJniArray instance that wraps it.

Constraints

Participates in overload resolution only if Container is a container that stores elements of a JNI type or equivalent C++ type, and provides a forward iterator.

The specialization of the constructed QJniArray depends on the value type of the container. For a Container<T> (such as e.g. QList<T>) it will typically be QJniArray<T>, with the following exceptions:

ContainerSpecialization
QByteArrayQJniArray<jbyte>
QStringListQJniArray<jstring>
Container::value_typeSpecialization
QJniObjectQJniArray<jobject>

See also QJniArray::toContainer().

bool QJniArrayBase::isEmpty() const

Returns true if the array has size 0; otherwise returns false.

An invalid array is always empty.

isValid(), size()

bool QJniArrayBase::isValid() const

Returns whether the QJniArray object wraps a valid `jobject`. For invalid QJniArray instances, object() returns nullptr. Iterating over an invalid object is safe (begin() will return the same as end()), and calling toContainer() on an invalid array will return an empty container.

See also QJniObject::isValid(), object(), and QJniArray::toContainer().

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

Returns the object held by the QJniArray as type T, which can be one of the JNI Object Types.

QJniArrayBase::size_type QJniArrayBase::size() const

Returns the size of the array.

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

Swaps this array object with other. This operation is very fast and never fails.

QJniObject QJniArrayBase::operator QJniObject() const

Returns a QJniObject wrapping the same jobject as this QJniArray instance.

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

Move-assigns other to this QJniArrayBase instance.

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

Copy-assigns other to this QJniArrayBase instance.

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