Results 1 to 9 of 9

Thread: How to redirect to a URL in Qt

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to redirect to a URL in Qt

    Hi

    If the url you give redirects to some other URL then how to fetch the redirected URL.
    Please provide some Qt Apis to be used on Linux

  2. #2
    Join Date
    Feb 2006
    Posts
    32
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to redirect to a URL in Qt

    The QNetworkReply/QNetworkRequest seems to help you there (use it together with the QNetworkAccessManager):
    "QNetworkReply::NoError 0 no error condition. Note: When the HTTP protocol returns a redirect no error will be reported. You can check if there is a redirect with the QNetworkRequest::RedirectionTargetAttribute attribute."
    Hope you can figure the rest out by yourself (I have never used it..)

  3. #3
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to redirect to a URL in Qt

    I assume You use QTcpSocket
    302 reply aka redirection contains new URL, simply paresout that information close current connection and connect to the new host or simply do new GET request if it is same host.

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to redirect to a URL in Qt

    Is it possible to do this through QtWebKit module?

  5. #5
    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: How to redirect to a URL in Qt

    QtWebKit uses QNetworkAccessManager for its networking capabilities. It should handle redirects automatically.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to redirect to a URL in Qt

    Well I have implementing interfaces to fetch gmail and msn accounts.

    Gmail interface works ok and loadFinished(ok) ok is true.

    MSN interface is a bit problematic.. It's loadFinished(ok) ok is false.

    I checked from the browser that the msn link is redirected.

    Moreover does the problem could be from cookies(disabled/enabled stuff)?

    Note: Oh by the way, i'm using qt 4.4.
    Last edited by zgulser; 29th March 2012 at 22:33.

  7. #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: How to redirect to a URL in Qt

    Redirection seems to work fine for me on bare QWebView dragged to a form in Designer (using http://doc.qt.nokia.com/latest as a URL which redirects to a different page).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to redirect to a URL in Qt

    Do cookie enabling/disabling have anything to do with this stuff?

    By the way in designer it worked fro me either. But from the source I just couldn't. It may be queuing signal-slot issue perhaps.


    Added after 34 minutes:


    I explored the web and found something like the following link refers to.

    https://bugreports.qt-project.org/br...ream-issue-tab

    it didn't mention the version t
    Last edited by zgulser; 29th March 2012 at 23:11.

  9. #9
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to redirect to a URL in Qt


Similar Threads

  1. QSettings Redirect into Database Table
    By ChrisW67 in forum Qt Programming
    Replies: 0
    Last Post: 17th December 2009, 22:51
  2. redirect qDebug() to file
    By sriky27 in forum Qt Programming
    Replies: 9
    Last Post: 17th March 2009, 20:21
  3. Replies: 4
    Last Post: 27th March 2008, 09:21
  4. Replies: 52
    Last Post: 10th December 2006, 14:32
  5. Redirect printf to QTextEdit?
    By Randulf in forum Qt Programming
    Replies: 9
    Last Post: 12th October 2006, 14:57

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.