PDA

View Full Version : void QWebView::loadFinished(bool ok) ok is always false



mspms
26th September 2016, 12:01
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.

anda_skoa
26th September 2016, 12:42
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,
_

mspms
26th September 2016, 13:26
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:


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?

anda_skoa
26th September 2016, 14:28
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


emit loadFinished(false);

or if it looks like this


bool someStatus = false;

emit loadFinished(someStatus);

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,
_

mspms
26th September 2016, 14:55
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


emit loadFinished(false);

or if it looks like this


bool someStatus = false;

emit loadFinished(someStatus);

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'?

anda_skoa
26th September 2016, 15:44
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,
_

d_stranz
26th September 2016, 17:09
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.

mspms
27th September 2016, 08:04
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?

anda_skoa
27th September 2016, 09:20
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 (http://code.woboq.org).



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,
_