From: Bas Schouten Date: Mon, 14 Aug 2023 20:22:59 +0000 (+0200) Subject: Revert "Downgrade to Qt5 for Pi0 compatibility." X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=4188d75b8fc40616eada40b3e1b5c44b93380030;p=qthomecontrol.git Revert "Downgrade to Qt5 for Pi0 compatibility." This reverts commit a4f496d259796c277cf5abcd0d53c7fa10972d01. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f09178..ff02d94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,53 +1,29 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) -project(test VERSION 0.1 LANGUAGES CXX) +project(qthomecontrol VERSION 0.1 LANGUAGES CXX) -set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +find_package(Qt6 6.2 COMPONENTS Quick REQUIRED) + if (UNIX) add_subdirectory ("paho.mqtt.c") endif(UNIX) -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Quick) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Quick) - -set(PROJECT_SOURCES - main.cpp - qml.qrc - mqttinterface.cpp - mqttinterface.h +qt_add_executable(appqthomecontrol + main.cpp + mqttinterface.cpp + mqttinterface.h ) -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(appqthomecontrol - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ) -# Define target properties for Android with Qt 6 as: -# set_property(TARGET test APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR -# ${CMAKE_CURRENT_SOURCE_DIR}/android) -# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation -else() - if(ANDROID) - add_library(appqthomecontrol SHARED - ${PROJECT_SOURCES} - ) -# Define properties for Android with Qt 5 after find_package() calls as: -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") - else() - add_executable(appqthomecontrol - ${PROJECT_SOURCES} - ) - endif() -endif() - -target_link_libraries(appqthomecontrol - PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick) +qt_add_qml_module(appqthomecontrol + URI qthomecontrol + VERSION 1.0 + QML_FILES main.qml + SOURCES + mqttinterface.h mqttinterface.cpp +) set_target_properties(appqthomecontrol PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com @@ -59,6 +35,9 @@ set_target_properties(appqthomecontrol PROPERTIES target_include_directories (appqthomecontrol PRIVATE paho.mqtt.c/src) +target_link_libraries(appqthomecontrol + PRIVATE Qt6::Quick) + if (WIN32) target_link_libraries (appqthomecontrol PRIVATE ${CMAKE_SOURCE_DIR}/paho.mqtt.c/src/Release/paho-mqtt3a.lib ${CMAKE_SOURCE_DIR}/paho.mqtt.c/src/Release/paho-mqtt3c.lib) endif (WIN32) @@ -69,8 +48,3 @@ endif(UNIX) install(TARGETS appqthomecontrol BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -if(QT_VERSION_MAJOR EQUAL 6) - qt_import_qml_plugins(qthomecontrol) - qt_finalize_executable(qthomecontrol) -endif() diff --git a/main.cpp b/main.cpp index 2124962..e4ddce2 100644 --- a/main.cpp +++ b/main.cpp @@ -1,19 +1,13 @@ #include #include -#include "mqttinterface.h" int main(int argc, char *argv[]) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif QGuiApplication app(argc, argv); - qmlRegisterType("QtHomeControl", 1, 0, "MQTTInterface"); - QQmlApplicationEngine engine; - const QUrl url(QStringLiteral("qrc:/main.qml")); + const QUrl url(u"qrc:/qthomecontrol/main.qml"_qs); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) diff --git a/main.qml b/main.qml index b761750..b5b938d 100644 --- a/main.qml +++ b/main.qml @@ -1,6 +1,7 @@ -import QtQuick 2.15 -import QtQuick.Window 2.15 -import QtHomeControl 1.0 +import QtQuick +import QtQuick.Controls 6.3 +import QtQuick.Layouts 6.3 +import qthomecontrol Window { width: 720 @@ -13,6 +14,22 @@ Window { id: mqttinterface } + Slider { + id: slider + x: 13 + y: 534 + width: 695 + height: 178 + live: true + antialiasing: false + topPadding: 0 + orientation: Qt.Horizontal + snapMode: RangeSlider.SnapOnRelease + stepSize: 1 + to: 100 + value: 0 + } + Text { id: text1 x: 206 diff --git a/mqttinterface.h b/mqttinterface.h index e2e4340..1b54a9a 100644 --- a/mqttinterface.h +++ b/mqttinterface.h @@ -2,7 +2,7 @@ #define MQTTINTERFACE_H #include -#include +#include #include #include "MQTTClient.h" diff --git a/qml.qrc b/qml.qrc deleted file mode 100644 index 5f6483a..0000000 --- a/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - main.qml - -