Results 1 to 9 of 9

Thread: void QWebView::loadFinished(bool ok) ok is always false

  1. #1
    Join Date
    Sep 2016
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default void QWebView::loadFinished(bool ok) ok is always false

    I am using Qt signals and slots. I use the following signal-slot call.
    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finishedLoadNotification(bool)));

    When the signal loadFinished is emitted, the slot finishedLoadNotification is called. In finishedLoadNotification, the variable 'ok' is always false. I want to know where the value of 'ok' is being set to false. From the code, I have not been able to find the value of 'ok'. Can you please help me in finding out where the variable 'ok' is set to false.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    The values transported by a signal are specified at the point of emit.

    Somewhere the code of "this" has an emit loadFinished() and the value passed to that loadFinished() is the one you are receiving in the slot.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2016
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    Quote Originally Posted by anda_skoa View Post
    The values transported by a signal are specified at the point of emit.

    Somewhere the code of "this" has an emit loadFinished() and the value passed to that loadFinished() is the one you are receiving in the slot.

    Cheers,
    _
    From the code it is not clear where the value of 'ok' is initialized to false. It is not clear where the value of 'ok' passed to loadFinished and finishedLoadNotification is set to false. Can you please help me where the value of 'ok' passed to finishedLoadNotification is set to false?


    Added after 32 minutes:


    Quote Originally Posted by anda_skoa View Post
    The values transported by a signal are specified at the point of emit.

    Somewhere the code of "this" has an emit loadFinished() and the value passed to that loadFinished() is the one you are receiving in the slot.

    Cheers,
    _
    The signal is emitted by the QT framework. We are not emitting the signal in the code. Hence we are not able to find out where the value of ok is set to false. Can you share your feedback?
    Last edited by mspms; 26th September 2016 at 13:26.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    It doesn't matter if the signal is emitted in your own code or in Qt's code, the emit always works the same way.

    The values passed to the signal at emit are the values the slots receive.

    E.g. if the emit code looks like this
    Qt Code:
    1. emit loadFinished(false);
    To copy to clipboard, switch view to plain text mode 
    or if it looks like this
    Qt Code:
    1. bool someStatus = false;
    2.  
    3. emit loadFinished(someStatus);
    To copy to clipboard, switch view to plain text mode 
    then the slot will receive "false".

    The signal/slot connection just transports the values to the slot, the value itself is determined by the code that emits the signal.

    Cheers,
    _

  5. #5
    Join Date
    Sep 2016
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    Quote Originally Posted by anda_skoa View Post
    It doesn't matter if the signal is emitted in your own code or in Qt's code, the emit always works the same way.

    The values passed to the signal at emit are the values the slots receive.

    E.g. if the emit code looks like this
    Qt Code:
    1. emit loadFinished(false);
    To copy to clipboard, switch view to plain text mode 
    or if it looks like this
    Qt Code:
    1. bool someStatus = false;
    2.  
    3. emit loadFinished(someStatus);
    To copy to clipboard, switch view to plain text mode 
    then the slot will receive "false".

    The signal/slot connection just transports the values to the slot, the value itself is determined by the code that emits the signal.

    Cheers,
    _
    What could be the reason why the QT code is emitting a false value to 'ok'?

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    For the unlikely case that the documentation of the signal does not contain that, you could look at the code where the signal is emitted.

    Cheers,
    _

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,972
    Thanks
    277
    Thanked 808 Times in 797 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finishedLoadNotification(bool)));
    What is the type (class) of "this" in your code? Have you derived your own class from the QWebView base class that defines this signal? Otherwise, it is not possible for you to connect to the signal unless your own class has defined it. You would get a run-time complaint from Qt that the signal does not exist.

    According to the docs, the signal will be emitted with a "false" status if there is an error. Most likely, the URL you are trying to load contains malformed HTML or some other features that QWebView and QtWebKit do not support:

    QtWebKit provides facilities for rendering of HyperText Markup Language (HTML), Extensible HyperText Markup Language (XHTML) and Scalable Vector Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and scripted with JavaScript.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  8. #8
    Join Date
    Sep 2016
    Posts
    4
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    Quote Originally Posted by anda_skoa View Post
    For the unlikely case that the documentation of the signal does not contain that, you could look at the code where the signal is emitted.

    Cheers,
    _
    We dont have access to the QT code where the signal is emitted. Can you please let us know any alternative method of determining where 'ok' is set to false?

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: void QWebView::loadFinished(bool ok) ok is always false

    Quote Originally Posted by mspms View Post
    We dont have access to the QT code where the signal is emitted.
    Of course you do.
    The Qt sources are part of every download, the code repository is publically accessible and there is a web base code browser.

    Quote Originally Posted by mspms View Post
    Can you please let us know any alternative method of determining where 'ok' is set to false?
    Alternatively set a break point in your slot, look at the call stack, find the method inside QtQWebKit before the signal handling code in QObject, set a break point there.

    In any case, as d_stranz has said, the signal is documented.

    Cheers,
    _

Similar Threads

  1. QWevView loadFinished iframes
    By Ini in forum Qt Programming
    Replies: 0
    Last Post: 26th January 2016, 18:22
  2. loadFinished() signal not emitted
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 0
    Last Post: 27th June 2013, 12:21
  3. QWebpage always return false for signal loadfinished
    By QtVenkat in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2010, 20:50
  4. Replies: 4
    Last Post: 28th April 2010, 09:50
  5. diffrence between void and virtual void
    By raphaelf in forum General Programming
    Replies: 2
    Last Post: 23rd February 2006, 13:58

Tags for this Thread

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.