Init QML project

This commit is contained in:
Arnaud 2026-01-22 18:52:53 +04:00
parent 7eab703594
commit 16c440c2b1
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F
3 changed files with 64 additions and 0 deletions

42
qml/CMakeLists.txt Normal file
View File

@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.16)
project(qml VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Quick)
qt_standard_project_setup(REQUIRES 6.8)
qt_add_executable(appqml
main.cpp
)
qt_add_qml_module(appqml
URI qml
VERSION 1.0
QML_FILES
Main.qml
)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(appqml PROPERTIES
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appqml
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(appqml
PRIVATE Qt6::Quick
)
include(GNUInstallDirs)
install(TARGETS appqml
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

8
qml/Main.qml Normal file
View File

@ -0,0 +1,8 @@
import QtQuick
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
}

14
qml/main.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char* argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("qml", "Main");
return app.exec();
}