Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Display device's IP address
QtWS25 Last Chance

Display device's IP address

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qmlqtquicknetwork
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • lopeztelL Offline
    lopeztelL Offline
    lopeztel
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      Example doc

      (Z(:^

      lopeztelL 1 Reply Last reply
      2
      • sierdzioS sierdzio

        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.

        Example doc

        lopeztelL Offline
        lopeztelL Offline
        lopeztel
        wrote on last edited by
        #3

        @sierdzio thanks a lot for the pointer and example document, I will look into this

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved