diff --git a/examples/qml_features/qml/images/images.qrc b/examples/qml_features/qml/images/images.qrc new file mode 100644 index 000000000..425f9d1f2 --- /dev/null +++ b/examples/qml_features/qml/images/images.qrc @@ -0,0 +1,5 @@ + + + red.png + + diff --git a/examples/qml_features/qml/images/images.qrc.license b/examples/qml_features/qml/images/images.qrc.license new file mode 100644 index 000000000..a49ba438d --- /dev/null +++ b/examples/qml_features/qml/images/images.qrc.license @@ -0,0 +1,4 @@ +SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +SPDX-FileContributor: Andrew Hayzen + +SPDX-License-Identifier: MIT OR Apache-2.0 diff --git a/examples/qml_features/qml/images/red.png b/examples/qml_features/qml/images/red.png new file mode 100644 index 000000000..91af51dd1 Binary files /dev/null and b/examples/qml_features/qml/images/red.png differ diff --git a/examples/qml_features/qml/images/red.png.license b/examples/qml_features/qml/images/red.png.license new file mode 100644 index 000000000..a49ba438d --- /dev/null +++ b/examples/qml_features/qml/images/red.png.license @@ -0,0 +1,4 @@ +SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +SPDX-FileContributor: Andrew Hayzen + +SPDX-License-Identifier: MIT OR Apache-2.0 diff --git a/examples/qml_features/rust/build.rs b/examples/qml_features/rust/build.rs index e88889249..2772bb0dc 100644 --- a/examples/qml_features/rust/build.rs +++ b/examples/qml_features/rust/build.rs @@ -57,6 +57,8 @@ fn main() { // Ensure that Quick module is linked, so that cargo test can work. // In a CMake project this isn't required as the linking happens in CMake. .qt_module("Quick") + // Import a Qt resource file + .qrc("../qml/images/images.qrc") .with_opts(cxx_qt_lib_headers::build_opts()) .build(); } diff --git a/examples/qml_features/tests/tst_qrc.qml b/examples/qml_features/tests/tst_qrc.qml new file mode 100644 index 000000000..c9f703579 --- /dev/null +++ b/examples/qml_features/tests/tst_qrc.qml @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +// SPDX-FileContributor: Andrew Hayzen +// +// SPDX-License-Identifier: MIT OR Apache-2.0 +import QtQuick 2.12 +import QtTest 1.12 + +TestCase { + name: "QrcTests" + + Component { + id: componentImage + + Image { + + } + } + + function test_image(data) { + const image = createTemporaryObject(componentImage, null, { + "source": data.source, + }); + + compare(image.status, data.status); + } + + function test_image_data() { + return [ + { + tag: "valid", source: "qrc:/images/red.png", status: Image.Ready, + tag: "invalid", source: "qrc:/images/invalid.png", status: Image.Error, + } + ] + } +}