Results 1 to 7 of 7

Thread: Can't get webpage to open using 'QHttp'

  1. #1
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Red face Can't get webpage to open using 'QHttp'

    Hi,
    I tried to implement the 'QHttp' example given in the Qt documents.
    What I want is that when I click "openTrolltech",the Trolltech webpage should open up.

    The code I am using is a slightly cropped version of the one given in the docs--
    Qt Code:
    1. void ImageViewer::openurl()
    2. {
    3. QHttp *http=new QHttp(this);
    4. http->setHost("www.trolltech.com");
    5. http->get(QUrl::toPercentEncoding("/index.html"));
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 

    It's not showing any error but the page/Browser isn't opening up.
    I added QT+=network in the .pro file and added the proper header files.
    What's wrong with the code ?Please advice.
    Thanks in advance.
    If everything seems to be going well, you have obviously overlooked something.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't get webpage to open using 'QHttp'

    The code above only schedules a download of the file but it doesn't store it anywhere nor show it anywhere.

  3. #3
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Can't get webpage to open using 'QHttp'

    Hi,
    could you please tell me the procedure for displaying the webpage?Thanks.
    If everything seems to be going well, you have obviously overlooked something.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't get webpage to open using 'QHttp'

    Use QWebView.

  5. The following user says thank you to wysota for this useful post:

    rishiraj (30th January 2009)

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Can't get webpage to open using 'QHttp'

    Or QDesktopServices::openUrl() if you want to show the page in an external web browser.
    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    rishiraj (30th January 2009)

  8. #6
    Join Date
    Dec 2008
    Location
    My spaceship needs repairs..so, I am stuck on beautiful earth
    Posts
    98
    Thanks
    25
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Post Re: Can't get webpage to open using 'QHttp'

    Hi,
    I tried 'QWebView' but,I guess I missed something cause I am getting a blank widget
    (See attachment)
    Didn't make many changes in the code given in the documentation--
    Qt Code:
    1. QWebView *view=new QWebView();
    2. view->load(QUrl("http://www.google.com/"));
    3. view->show();
    To copy to clipboard, switch view to plain text mode 
    Also added QT +=webkit in the .pro file.
    Where am I going wrong?
    **it worked with QDesktopServices but,I would appreciate it if anyone could tell me where I am going wrong while using QWebView.
    Attached Images Attached Images
    If everything seems to be going well, you have obviously overlooked something.

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Can't get webpage to open using 'QHttp'

    I don't think the code you pasted has anything to do with this, it is more or less correct. Maybe something is blocking the connection?

Similar Threads

  1. From QHttp to QHttp over SSL
    By Nyphel in forum Newbie
    Replies: 1
    Last Post: 3rd July 2007, 11:41

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.