当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - QNetworkReply::UnknownNetworkError when running outside IDE

问题描述:

I have the following code:

QNetworkAccessManager nam;

QEventLoop loop;

QNetworkRequest request(_client.url());

QNetworkReply *reply = nam.get(request);

connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));

loop.exec();

info = QSharedPointer<UpdateInformation>(new UpdateInformation(reply));

reply->deleteLater();

This code works fine when executed from Qt Creator, even when another application that runs in the IDE invokes this one (via QProcess).

However, when ran outside the IDE, the QNetworkReply is empty (its length() is 0). I'm assuming this is caused by a misplaced/wrong version dependency. I copied the needed DLLs from *c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin* and the application runs just fine. How can I find out which DLLs the IDE actually uses to run it? If that's not the problem, how can I gain more information?

Edit: after restructuring the code to connect to QNetworkAccessManager's finished() signal, I found that the reply->error() is QNetworkReply::UnknownNetworkError. I still have no clue about the cause though.

Solution (it won't let me answer it and there no way I'll wait 6 hours from now):

Ok, so I managed to solve it. The clue was reply->errorString() which said "Error creating SSL context ()". That quickly led me to remember that the URL was actually a HTTPS url. After a little digging around I found that in order to use the SSL functionality in Qt (and so HTTPS), one needs to copy the following openssl DLLs to the application folder: libeay32.dll and ssleay32.dll. And that's it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: