Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT4 - Using host/PC name in QUrl
Forum Updated to NodeBB v4.3 + New Features

QT4 - Using host/PC name in QUrl

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 2 Posters 305 Views 1 Watching
  • 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.
  • H Offline
    H Offline
    Hariprasasth
    wrote on last edited by
    #1

    Hello,

    I am sending REST request to server. Using QUrl I am formatting the request.

    QUrl requestedUrl;
    requestedUrl.setHost("169.29.2.101");
    requestedUrl.setPort(8081);
    requestedUrl.setPath("/ticket/services/config");
    requestedUrl.setScheme("http");
    QNetworkRequest req(requestedUrl);
    reply = qnam.get(req);
    

    The above code works correctly. I would like to replace IP address with host/PC name. Both client and server are running in same domain network so no proxy issue.

    requestedUrl.setHost("169.29.2.101");
    TO
    requestedUrl.setHost("EAGLE-1");
    

    Should I use QHostinfo to get IP from host name or Is there way to specify it in QUrl?

    Thanks,
    Hari

    Pablo J. RoginaP 1 Reply Last reply
    0
    • H Hariprasasth

      Hello,

      I am sending REST request to server. Using QUrl I am formatting the request.

      QUrl requestedUrl;
      requestedUrl.setHost("169.29.2.101");
      requestedUrl.setPort(8081);
      requestedUrl.setPath("/ticket/services/config");
      requestedUrl.setScheme("http");
      QNetworkRequest req(requestedUrl);
      reply = qnam.get(req);
      

      The above code works correctly. I would like to replace IP address with host/PC name. Both client and server are running in same domain network so no proxy issue.

      requestedUrl.setHost("169.29.2.101");
      TO
      requestedUrl.setHost("EAGLE-1");
      

      Should I use QHostinfo to get IP from host name or Is there way to specify it in QUrl?

      Thanks,
      Hari

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @hariprasasth said in QT4 - Using host/PC name in QUrl:

      Is there way to specify it in QUrl?

      Yes, you can specify the hostname in the URL. And you can also use QHostInfo class for host names lookup & resolution, but everything ends up being a question of having a working name resolution service in the underlying OS being it by means of a DNS server or by manually configuring host name files (i.e. /etc/hosts in *nix)

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1

      • Login

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