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")
qt_add_qml_module(appqthomecontrol
URI qthomecontrol
VERSION 1.0
- QML_FILES main.qml
+ QML_FILES Main.qml
SOURCES
mqttinterface.h mqttinterface.cpp
)
--- /dev/null
+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
+ }
+}
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();
}
+++ /dev/null
-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
- }
-}
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)