From cf870a6cb9aab715d6857c32448f5e48f0c14c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Delobel?= Date: Tue, 25 Mar 2025 10:49:29 +0100 Subject: [PATCH] Avec bouton --- 2024/tp4_reseau/NetIf.qml | 8 ++++++++ 2024/tp4_reseau/main.qml | 3 ++- 2024/tp4_reseau/networkinterface.cpp | 5 +++++ 2024/tp4_reseau/networkinterface.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/2024/tp4_reseau/NetIf.qml b/2024/tp4_reseau/NetIf.qml index 25779bb..2a14451 100644 --- a/2024/tp4_reseau/NetIf.qml +++ b/2024/tp4_reseau/NetIf.qml @@ -1,10 +1,12 @@ import QtQuick 2.15 +import QtQuick.Controls 2.15 Row { property alias name: name.text property alias address: address.text + spacing: 40 Text { id: name @@ -16,4 +18,10 @@ Row { font.pointSize: 36 anchors.verticalCenter: parent.verticalCenter } + + Button { + text: "Shutdown" + onClicked: { netint.shutdown() } + anchors.verticalCenter: parent.verticalCenter + } } diff --git a/2024/tp4_reseau/main.qml b/2024/tp4_reseau/main.qml index 72ff705..3fbd731 100644 --- a/2024/tp4_reseau/main.qml +++ b/2024/tp4_reseau/main.qml @@ -7,10 +7,11 @@ Window { visible: true title: qsTr("Hello World") + + NetIf { name: netint.name address: netint.address } - } diff --git a/2024/tp4_reseau/networkinterface.cpp b/2024/tp4_reseau/networkinterface.cpp index 3cb994f..ffd2dff 100644 --- a/2024/tp4_reseau/networkinterface.cpp +++ b/2024/tp4_reseau/networkinterface.cpp @@ -33,3 +33,8 @@ void NetworkInterface::setAddress(const QString &newAddress) m_address = newAddress; emit addressChanged(); } + +void NetworkInterface::shutdown() +{ + qWarning() << "Shutting down interface"; +} diff --git a/2024/tp4_reseau/networkinterface.h b/2024/tp4_reseau/networkinterface.h index c577dee..4f56675 100644 --- a/2024/tp4_reseau/networkinterface.h +++ b/2024/tp4_reseau/networkinterface.h @@ -18,7 +18,7 @@ public: QString address() const; void setAddress(const QString &newAddress); - + Q_INVOKABLE void shutdown(); signals: void nameChanged(); void addressChanged();