Add skeleton for a QML application

This commit is contained in:
jordi fita mas 2024-12-14 01:19:20 +01:00
parent 7c6bac1986
commit 49b2c035ad
5 changed files with 80 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,4 +1,7 @@
/.idea/
/build/
/locale/
/po/*.pot
/demo.sql
CMakeLists.txt.user*
.qmlls.ini

16
CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.16)
project(camper VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS
Quick
QuickControls2
)
qt_standard_project_setup(REQUIRES 6.5)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(src)

31
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,31 @@
qt_add_executable(${PROJECT_NAME}
main.cpp
)
qt_add_qml_module(${PROJECT_NAME}
URI Camper
VERSION 1.0
DEPENDENCIES QtCore
QML_FILES
Main.qml
)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER ws.tandem.${PROJECT_NAME}
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(${PROJECT_NAME}
PRIVATE Qt6::Quick
PRIVATE Qt6::QuickControls2
)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

9
src/Main.qml Normal file
View File

@ -0,0 +1,9 @@
import QtQuick
import QtQuick.Controls
ApplicationWindow {
height: 480
title: qsTr("Camper")
visible: true
width: 640
}

21
src/main.cpp Normal file
View File

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