Results 1 to 2 of 2

Thread: unable to get host name from QUrl::host() ?

  1. #1
    Join Date
    May 2010
    Posts
    12
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default unable to get host name from QUrl::host() ?

    #include <QUrl>
    #include<QDebug>
    #include<QFileInfo>

    int main()
    {

    QUrl url("ftp.trolltech.com/mirrors");

    if(!url.isValid())
    qDebug() << "Url is invalid";

    // url.setHost(url.toString());
    // url.setHost(url.path());
    qDebug() << "url.host() = " << url.host(); // not getting host name ......???????

    qDebug() << "Url.path() = "<<url.path();
    qDebug() << "url.scheme() = " <<url.scheme();
    qDebug() << "QFileInfo(url.path()).fileName() = "<<QFileInfo(url.path()).fileName();
    qDebug() << "url.port() = " << url.port(21);

    // The other case tried by keeping scheme is as shown below .. still not getting hostname ..?????

    QUrl url1("ftp:172.18.217.90");
    qDebug() << "url1.host() = " << url1.host();

    return 0;
    }

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: unable to get host name from QUrl::host() ?

    Maybe you forgot the ftp:// or http:// in your url.
    Qt Code:
    1. //QUrl url("ftp.trolltech.com/mirrors");
    2. QUrl url("ftp://ftp.trolltech.com/mirrors");
    3.  
    4. //QUrl url1("ftp:172.18.217.90");
    5. QUrl url1("ftp://172.18.217.90"); // or QUrl url1("http://172.18.217.90"); // btw, pinging this ip gives me request time out.
    6. qDebug() << "url1.host() = " << url1.host();
    To copy to clipboard, switch view to plain text mode 
    Last edited by saa7_go; 17th July 2010 at 12:02. Reason: updated contents

Similar Threads

  1. How to host the other process's window in a program?
    By tszzp in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2010, 10:34
  2. Replies: 6
    Last Post: 28th October 2009, 13:17
  3. x86 host, mips target
    By zeitcheist in forum Installation and Deployment
    Replies: 1
    Last Post: 4th May 2009, 04:35
  4. QHttp : Host vs IP adress
    By Nyphel in forum Newbie
    Replies: 5
    Last Post: 15th April 2007, 11:21
  5. load pixmap from another host
    By raphaelf in forum Newbie
    Replies: 16
    Last Post: 31st August 2006, 22:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.