Display device's IP address
Solved
QML and Qt Quick
-
Hello, I guess this is kind of a basic question but I was wondering how to display a device's IP address (kind of like doing
ifconfig
in a terminal and then just getting the IPv4 address ) on a label of a QtQuick application.I know it is possible to get the information from the C++ side but not sure how to link this to the qml side or if it is possible to do it from the qml side...
#include <QtNetwork> const QHostAddress localhostAddress = QHostAddress(QHostAddress::LocalHost);
I'm guessing I also need
QT+= network
in the .pro file?Thanks in advance for any help
-
A standard way is to expose a root context property to QML, containing your data. If you need a more sophisticated solution, create a class which will expose the address as QObject property.