Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.6.1, 6.6
-
None
Description
Hello,
I have a very strange case going on. Repro attached.
Basically:
qml/Style.qml:
pragma Singleton import QtQuick QtObject { readonly property int foo: 250 Component.onCompleted: { console.log("hi from singleton") } }
qml/Main.qml:
import QtQuick Window { visible: true Component.onCompleted: console.log(Style.foo) }
When I do this, I get "undefined" on the console, and I don't see "hi from singleton" showing up.
To make it work, it is sufficient to move Main.qml one folder above. e.g. here are the three scenarios:
Scenario A: fails
qml/Main.qml
qml/Style.qml
Scenario B: works
./Main.qml
qml/Style.qml
Scenario C: works
./Main.qml
./Style.qml
I believe that if Scenario B and C work, then scenario A not working is a bug.
Bug originally experienced on macOS but reduced and reproduced on Linux.
CMake for the record:
cmake_minimum_required(VERSION 3.16) project(singleton-bug VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt6 6.5 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.5) set_source_files_properties(qml/Style.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE ) qt_add_executable(appsingleton-bug main.cpp ) qt_add_qml_module(appsingleton-bug URI singleton-bug VERSION 1.0 QML_FILES # Main.qml # OK qml/Main.qml # Buggy qml/Style.qml ) target_link_libraries(appsingleton-bug PRIVATE Qt6::Quick )
Attachments
Issue Links
- relates to
-
QTBUG-111763 Consider support for nested directories in QML modules
- Closed