From: Bas Schouten Date: Mon, 14 Aug 2023 21:55:42 +0000 (+0200) Subject: Update app to Qt 6.5 and update IP. X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=0e5da8f18d84457b72f5842dc10a6a5a7090ad32;p=qthomecontrol.git Update app to Qt 6.5 and update IP. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ff02d94..11378e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,9 @@ project(qthomecontrol VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt6 6.2 COMPONENTS Quick REQUIRED) +find_package(Qt6 6.5 COMPONENTS Quick REQUIRED) + +qt_standard_project_setup(REQUIRES 6.5) if (UNIX) add_subdirectory ("paho.mqtt.c") @@ -20,7 +22,7 @@ qt_add_executable(appqthomecontrol qt_add_qml_module(appqthomecontrol URI qthomecontrol VERSION 1.0 - QML_FILES main.qml + QML_FILES Main.qml SOURCES mqttinterface.h mqttinterface.cpp ) diff --git a/Main.qml b/Main.qml new file mode 100644 index 0000000..7b52a7a --- /dev/null +++ b/Main.qml @@ -0,0 +1,56 @@ +import QtQuick +import QtQuick.Controls 6.3 +import QtQuick.Layouts 6.3 +import qthomecontrol + +Window { + width: 720 + height: 720 + visible: true + color: "#000000" + title: qsTr("Home Control") + + MQTTInterface { + 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 + y: 114 + width: 309 + height: 129 + color: "#ffffff" + text: mqttinterface.bedroomTemperature.toFixed(1) + " °C" + font.pixelSize: 92 + horizontalAlignment: Text.AlignHCenter + } + + Text { + id: text2 + x: 206 + y: 285 + width: 309 + height: 129 + color: "#ffffff" + text: mqttinterface.bedroomHumidity.toFixed(0) + " %" + font.pixelSize: 92 + horizontalAlignment: Text.AlignHCenter + } +} diff --git a/main.cpp b/main.cpp index e4ddce2..6086143 100644 --- a/main.cpp +++ b/main.cpp @@ -7,13 +7,10 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - 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) - QCoreApplication::exit(-1); - }, Qt::QueuedConnection); - engine.load(url); + QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, + &app, []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + engine.loadFromModule("qthomecontrol", "Main"); return app.exec(); } diff --git a/main.qml b/main.qml deleted file mode 100644 index b5b938d..0000000 --- a/main.qml +++ /dev/null @@ -1,56 +0,0 @@ -import QtQuick -import QtQuick.Controls 6.3 -import QtQuick.Layouts 6.3 -import qthomecontrol - -Window { - width: 720 - height: 720 - visible: true - color: "#000000" - title: qsTr("Hello World") - - MQTTInterface { - 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 - y: 114 - width: 309 - height: 129 - color: "#ffffff" - text: mqttinterface.bedroomTemperature.toFixed(1) + " °C" - font.pixelSize: 92 - horizontalAlignment: Text.AlignHCenter - } - - Text { - id: text2 - x: 206 - y: 285 - width: 309 - height: 129 - color: "#ffffff" - text: mqttinterface.bedroomHumidity.toFixed(0) + " %" - font.pixelSize: 92 - horizontalAlignment: Text.AlignHCenter - } -} diff --git a/mqttinterface.cpp b/mqttinterface.cpp index cb8b81d..2958895 100644 --- a/mqttinterface.cpp +++ b/mqttinterface.cpp @@ -46,7 +46,7 @@ MQTTInterface::MQTTInterface(QObject *parent) MQTTClient_deliveryToken token; int rc; - MQTTClient_create(&mClient, "tcp://10.0.1.213:1883", "bedroom-thermostat-fe", + MQTTClient_create(&mClient, "tcp://10.0.1.225:1883", "bedroom-thermostat-fe", MQTTCLIENT_PERSISTENCE_NONE, NULL); if ((rc = MQTTClient_setCallbacks(mClient, this, connlost, msgarrvd, delivered)) != MQTTCLIENT_SUCCESS)