diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fc8538..509e518 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,15 +75,15 @@ if(NOT DEFINED CMAKE_DEBUG_POSTFIX) endif() if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") endif() if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") endif() if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -139,6 +139,13 @@ if(MSVC) endif() endif() +if(NOT DEFINED QML_IMPORT_PATH) + set(QML_IMPORT_PATH) +endif() +list(APPEND QML_IMPORT_PATH "${PROJECT_BINARY_DIR}/qml") +list(REMOVE_DUPLICATES QML_IMPORT_PATH) +set(QML_IMPORT_PATH ${QML_IMPORT_PATH} CACHE STRING "Qt Creator extra QML import paths" FORCE) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui) diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt index 226121d..e46b922 100644 --- a/examples/quick/CMakeLists.txt +++ b/examples/quick/CMakeLists.txt @@ -51,9 +51,9 @@ add_executable(Quick ${SOURCES}) if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2) set(QML_SOURCES - "Window.qml" - "ApplicationWindow.qml" - "HomePage.qml" + "qml/Window.qml" + "qml/ApplicationWindow.qml" + "qml/HomePage.qml" ) set_source_files_properties(${QML_SOURCES} PROPERTIES QT_DISCARD_FILE_CONTENTS TRUE @@ -62,7 +62,9 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2) URI Demo VERSION 1.0 IMPORT_PATH "${PROJECT_BINARY_DIR}/qml" + OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/qml/Demo" RESOURCE_PREFIX "/" + NO_RESOURCE_TARGET_PATH IMPORTS QtQuick/auto DEPENDENCIES @@ -72,7 +74,7 @@ if(${QT_VERSION} VERSION_GREATER_EQUAL 6.2) ) qt_add_resources(Quick resources PREFIX - "/Demo" + "/" FILES "images/microsoft.svg" ) diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index d59584d..9dee8fd 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -103,6 +103,11 @@ int main(int argc, char *argv[]) }()); } + // Enable some helpful debugging messages. + if (!qEnvironmentVariableIsSet("QML_IMPORT_TRACE")) { + qputenv("QML_IMPORT_TRACE", FRAMELESSHELPER_BYTEARRAY_LITERAL("1")); + } + const auto engine = std::make_unique(); engine->rootContext()->setContextProperty( @@ -121,7 +126,7 @@ int main(int argc, char *argv[]) #endif #if !QMLTC_ENABLED - const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///Demo/HomePage.qml")); + const QUrl mainUrl(FRAMELESSHELPER_STRING_LITERAL("qrc:///qml/HomePage.qml")); #endif #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) diff --git a/examples/quick/ApplicationWindow.qml b/examples/quick/qml/ApplicationWindow.qml similarity index 98% rename from examples/quick/ApplicationWindow.qml rename to examples/quick/qml/ApplicationWindow.qml index b377085..4eed4cd 100644 --- a/examples/quick/ApplicationWindow.qml +++ b/examples/quick/qml/ApplicationWindow.qml @@ -105,7 +105,7 @@ FramelessApplicationWindow { left: parent.left right: parent.right } - windowIcon: "qrc:///Demo/images/microsoft.svg" + windowIcon: "qrc:///images/microsoft.svg" windowIconVisible: true } } diff --git a/examples/quick/HomePage.qml b/examples/quick/qml/HomePage.qml similarity index 100% rename from examples/quick/HomePage.qml rename to examples/quick/qml/HomePage.qml diff --git a/examples/quick/Window.qml b/examples/quick/qml/Window.qml similarity index 98% rename from examples/quick/Window.qml rename to examples/quick/qml/Window.qml index 6de5995..1bf98b3 100644 --- a/examples/quick/Window.qml +++ b/examples/quick/qml/Window.qml @@ -105,7 +105,7 @@ FramelessWindow { left: parent.left right: parent.right } - windowIcon: "qrc:///Demo/images/microsoft.svg" + windowIcon: "qrc:///images/microsoft.svg" windowIconVisible: true } } diff --git a/examples/quick/resources.qrc b/examples/quick/resources.qrc index 152647e..f6da674 100644 --- a/examples/quick/resources.qrc +++ b/examples/quick/resources.qrc @@ -1,8 +1,8 @@ - + images/microsoft.svg - Window.qml - ApplicationWindow.qml - HomePage.qml + qml/Window.qml + qml/ApplicationWindow.qml + qml/HomePage.qml