Results 1 to 5 of 5

Thread: Is the 'okay' parameter of QWebView::loadFinished() ever false?

  1. #1
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Is the 'okay' parameter of QWebView::loadFinished() ever false?

    I'm using QWebView to display an HTML page that is local to my machine. My code looks something like this:

    Qt Code:
    1. m_url = "file:///c:temp/foo.html";
    2.  
    3. connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished(bool)));
    4. m_webView->load( QUrl(m_url) );
    5.  
    6. .
    7. .
    8. .
    9.  
    10. void MyWindow::onLoadFinished(bool okay)
    11. {
    12. if ( ! okay )
    13. {
    14. QString errorMsg( tr("<html><body>An error occurred while trying to load %1.</body></html>").arg(m_url) );
    15. m_webView->setHtml(errorMsg);
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that 'okay' seems to always be true, even when:
    • the file doesn't exist
    • the file contains bad HTML
    • the file contains no HTML


    In a search of the Trolltech TaskTracker and googling, I didn't find any reports of this issue, so I'm thinking maybe there's something wrong with how I'm using QWebView. According to the docs, the boolean parameter of loadFinished() "will indicate whether the load was successful or any error occurred." Seems like at least one of the cases I listed above would elicit an error indication from loadFinished(), but that's not happening. Does anyone know if I'm doing something wrong or if this is just a bug in QWebView::loadFinished()?

  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: Is the 'okay' parameter of QWebView::loadFinished() ever false?

    Based on the source code of WebKit I can tell you there are two cases where the signal will be emitted with a value of false.
    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.


  3. #3
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?

    Hmm, FrameLoaderClientQt::dispatchDidFailLoad() and FrameLoaderClientQt::dispatchDidFailLoading() appear to be the only two places in the webkit source where the flag is set to false, but it doesn't appear that those functions are ever called (at least not within the webkit source). I guess I won't count on that flag being useful any time soon.

  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: Is the 'okay' parameter of QWebView::loadFinished() ever false?

    They are probably called somewhere in the webkit core. And even if not, it doesn't mean they won't be called tomorrow.
    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.


  5. #5
    Join Date
    Apr 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?

    I'm developing an embeddead app where page reloads is supposed to be completely invisible (if contens is unchanged, of cause).
    To set the url I:
    web_view->setUpdatesEnabled(false);
    web_view->load(QUrl(NewUrl));

    Then on the load
    void MainWindow::finishLoading(bool ok)
    {
    web_view->setUpdatesEnabled(true);
    }


    I can tell you that ok is ideed false now and then, I not sure why. Apperently it is called soon after with true. So I problaly need to only enable update if ok is true.
    Maybe its some specifik errorcode from the server. It does not appear to be a timeout as it comes quite fast.
    You right that missing files or fucked up html still generates ok=true. I guess it must be some specific errorcode from the server.

    I know, need to do some counting on the setUpdatesEnabled

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. QSslSocke::supportSsl() returns false
    By oscar in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2008, 18:51
  3. Problem with connect()
    By mrnor3 in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 14:05
  4. Error: BadMatch --> what's it?
    By mattia in forum Newbie
    Replies: 4
    Last Post: 9th June 2008, 12:20
  5. enabling a QTreeWidgetItem as false
    By Kapil in forum Newbie
    Replies: 2
    Last Post: 3rd March 2006, 07:32

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.