diff --git a/CMakeLists.txt b/CMakeLists.txt index da01a44..69aa130 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,3 +12,4 @@ set(CMAKE_PROJECT_LICENSE "${PROJECT_LICENSE}") add_subdirectory(pivoter) #add_subdirectory(core) add_subdirectory(src) +add_subdirectory(qmldemo) diff --git a/qmldemo/CMakeLists.txt b/qmldemo/CMakeLists.txt new file mode 100644 index 0000000..5235c10 --- /dev/null +++ b/qmldemo/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.16) + +project(demoForQmllsWhatsNew66 VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 6.4 REQUIRED COMPONENTS Quick) + +qt_standard_project_setup() + +add_subdirectory(MyModule) + +qt_add_executable(appdemoForQmllsWhatsNew66 + main.cpp +) + +qt_add_qml_module(appdemoForQmllsWhatsNew66 + URI demoForQmllsWhatsNew66 + QML_FILES Main.qml + RESOURCE_PREFIX / +) + +set_target_properties(appdemoForQmllsWhatsNew66 PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +target_link_libraries(appdemoForQmllsWhatsNew66 + PRIVATE Qt6::Quick myModule +) + +install(TARGETS appdemoForQmllsWhatsNew66 + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/qmldemo/Main.qml b/qmldemo/Main.qml new file mode 100644 index 0000000..9b825e6 --- /dev/null +++ b/qmldemo/Main.qml @@ -0,0 +1,51 @@ +import QtQuick +import QtQuick.Window +import MyModule + +Window { + width: 640 + height: 480 + visible: true + title: qsTr("Hello World") + + MyComponent { + } + component UnknownComponent: Item { + } + UnknownComponent { + } + + Item { + id: myItem + + property int i + } + property int i + property int childI: myItem.i + + function getI() { + f(1, 2, 3); + return myItem.i; + } + + function f(a, b, c) { + if (a) { + b = a + b; + } else { + a = a + myItem.i; + } + let sum = 0; + for (i = a; i < b; i = i + c) { + while (a) { + sum = sum + b - c + a * i; + { + let i = 32 // not a definition nor usage of i + i = 44 // neither + } + } + } + console.log(sum); + } + + property UnknownComponent myComponent +} diff --git a/qmldemo/MyModule/CMakeLists.txt b/qmldemo/MyModule/CMakeLists.txt new file mode 100644 index 0000000..25ec217 --- /dev/null +++ b/qmldemo/MyModule/CMakeLists.txt @@ -0,0 +1,6 @@ + +qt_add_qml_module(myModule + URI MyModule + QML_FILES MyComponent.qml + RESOURCE_PREFIX / +) diff --git a/qmldemo/MyModule/MyComponent.qml b/qmldemo/MyModule/MyComponent.qml new file mode 100644 index 0000000..fc51688 --- /dev/null +++ b/qmldemo/MyModule/MyComponent.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + property string data: "Hello World!" +} diff --git a/qmldemo/main.cpp b/qmldemo/main.cpp new file mode 100644 index 0000000..d14416f --- /dev/null +++ b/qmldemo/main.cpp @@ -0,0 +1,17 @@ +#include +#include + + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + const QUrl url(u"qrc:/demoForQmllsWhatsNew66/Main.qml"_qs); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, + &app, []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.load(url); + + return app.exec(); +}