Variation pour expliquer QmlRegisterType

flags
Francois DELOBEL 4 weeks ago
parent cf870a6cb9
commit f223c71103

@ -1,11 +1,12 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import trump.hatesScience 1.0
Row { Row {
property alias name: name.text property alias name: name.text
property alias address: address.text property alias address: address.text
property NetworkInterface iface
spacing: 40 spacing: 40
Text { Text {
@ -21,7 +22,10 @@ Row {
Button { Button {
text: "Shutdown" text: "Shutdown"
onClicked: { netint.shutdown() } onClicked: {
console.log("Sutting down")
parent.iface.shutdown()
}
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }

@ -24,6 +24,9 @@ int main(int argc, char *argv[])
Qt::QueuedConnection); Qt::QueuedConnection);
NetworkInterface ni{3}; NetworkInterface ni{3};
qmlRegisterUncreatableType<NetworkInterface>("trump.hatesScience",1,0,
"NetworkInterface",
"Don't build NetworkInterface from QML");
engine.rootContext()->setContextProperty("netint", &ni); engine.rootContext()->setContextProperty("netint", &ni);
engine.load(url); engine.load(url);

@ -12,6 +12,7 @@ Window {
NetIf { NetIf {
name: netint.name name: netint.name
address: netint.address address: netint.address
iface: netint
} }
} }

Loading…
Cancel
Save