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.
  • L Offline
    L Offline
    lopeztel
    wrote on 29 Mar 2020, 16:58 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
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 30 Mar 2020, 08:50 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(:^

      L 1 Reply Last reply 30 Mar 2020, 09:00
      2
      • S sierdzio
        30 Mar 2020, 08:50

        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

        L Offline
        L Offline
        lopeztel
        wrote on 30 Mar 2020, 09:00 last edited by
        #3

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

        1 Reply Last reply
        0

        2/3

        30 Mar 2020, 08:50

        • Login

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