October 25, 2010

Felix Felix
Lab Rat
92 posts

QNetworkReply::isFinished()

 

Hi

I have a problem with subclassing QNetworkReply.

When I make a Subclass and call isFinished i get always false as result, and have no way to change it manually since this method is only virtual in QNetworkReplyPrivate. But as the name says, this class doesnt belong to the public API so i can’t change it at that location.
So what can I do to get this method working correctly?

Felix

9 replies

October 25, 2010

Franzk Franzk
Lab Rat
830 posts

Just to get a clear view of what you want to achieve: Why do you want to subclass the QNetworkReply?

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

October 25, 2010

Felix Felix
Lab Rat
92 posts

yes, and in that subclass there is the problem with isFinished and isRunning

October 25, 2010

Franzk Franzk
Lab Rat
830 posts

That was not an answer to my question :). After a quick review the whole implementation leads me to believe the QNetworkReply isn’t there to be subclassed (by non-qnetwork code that is). If you really need to subclass this thing, you should have it depend on on the non-public API, I’m afraid.

That is why I wanted to know why you are trying to subclass it — what are you trying to achieve that you need this subclass for?

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

October 25, 2010

Felix Felix
Lab Rat
92 posts

ah sorry i didnt get the why in your question :)
several reasons: the first is to provide my own network protocol (QNetworkAccessManager provides a virtual createRequest method)
the second is to rewrite the Ftp part to enable resumePut and resumeGet which isnt provided by the default implementation

October 25, 2010

Volker Volker
Robot Herder
5428 posts

When you’re done with your work, you must emit signal finished().

You cannot do that in the constructor of your QNetworkReply subclass, because at that time the signal/slot connections in your client code were not setup!

Some more info on this in the Qt mailing list [lists.trolltech.com]

October 25, 2010

Felix Felix
Lab Rat
92 posts

i am emitting finished. That is noth the problem. I am talking about QNetworkReply::isFinished() not about the SIGNAL QNetworkReply::finished() .

I found no line in the Qt source where this Signal is connected internally. Also connecting it internally wouldnt solve my problem, since in QNetworkReplyPrivate the method isFinished always returns false. I cant change that private class to have a late binding on that function.

October 25, 2010

Volker Volker
Robot Herder
5428 posts

I overlooked that. That’s a bug, indeed. It’s already addressed and fixed by Nokia, see QTBUG-11737 [bugreports.qt.nokia.com], although it will be public not until Qt 4.8.0.

October 25, 2010

Felix Felix
Lab Rat
92 posts

thank you volker for the link.

Anyone has a suggestion for a workaround for now?

October 25, 2010

Volker Volker
Robot Herder
5428 posts

If you do not rely on a prebuilt Qt you can get the patch (there’s a link to the git commit on the bugtracker) and apply it to your sources.

 
  ‹‹ Getting the Ip address the from active NIC on the local computer      moc_MyApp.cpp:94: multiple definition of `MyApp::ValueChanged(int) const’ ---- first defined here MyApp.cpp ››

You must log in to post a reply. Not a member yet? Register here!