Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to use property change signal if used with setContextProperty()?

$
0
0
Hi everyone, I have problems writing my first qml/c++ app. Maybe someone can lend me a helping hand? My app should show some health states including network settings. Reading the “ipAddress” is no problem, but I get a parser error on “eth0.onIpAddressChanged”, saying the eth0 is unknown. Couldn’t be that much, but I havn’t found the problem/a solution yet. Thanks in advance, Horst cpp: class netData : public QObject { Q_OBJECT Q_PROPERTY(QString ipAddress READ getIpAddress WRITE setIpAddress NOTIFY ipAddressChanged)   QString getIpAddress(void) const; void setIpAddress(QString address);   signals:   void ipAddressChanged(QString addr); } main.cpp: ... context->setContextProperty("eth0", myNetData ); qml: Rectangle {     width: 360     height: 360       Text {         color: "#000000"         height: 20         x: 10         y: 10         id: text1         text: "ipAddr: " + eth0.ipAddress         font.weight: Font.Bold         font.pixelSize: 11         verticalAlignment: Text.AlignVCenter     }       eth0.onIpAddressChanged: {        text1.text = "ipAddr: " + addr;     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles