[Interest] a question about QNetworkAccessManager
Reinhardt Behm
rbehm at hushmail.com
Thu Mar 21 10:55:26 CET 2019
On Thursday 21 March 2019 10:29:09 Matej Košík wrote:
> Hi,
>
> On 3/20/19 11:03 AM, Reinhardt Behm wrote:
> > On Wednesday 20 March 2019 10:45:18 you wrote:
> >> Hi,
> >>
> >> I am new to Qt.
> >> Yesterday, I have learned about:
> >> - QNetworkAccessManager
> >> - QNetworkRequest
> >> - QNetworkReply
> >> (as I wanted to figure out how to make HTTP GET/POST request and process
> >> the responses).
> >>
> >> Here:
> >> https://doc.qt.io/qt-5/qnetworkaccessmanager.html#details
> >>
> >> I read:
> >> One QNetworkAccessManager instance should be enough for the whole Qt
> >>
> >> application.
> >>
> >> I do not understand what do I gain by that.
> >> Our application makes different HTTP requests.
> >> Each response must be handled differently.
> >> Why would we want to pipe all "finished" signals (generated by the
> >> QNetworkAccessManager) to the same set of slots? What sense would that
> >> make?
> >>
> >> ---
> >>
> >> Curiously,
> >> Matej
> >
> > Then simply don't do this. Connect the finished signal from the generated
> > QNetworkReply to the corresponding slot.
>
> Is the reliability of the following code
>
> I guess that we are supposed to something like this:
>
> QNetworkReply* reply = m_networkAccessManager->get(request);
> QObject::connect(reply, &QNetworkReply::finished, this,
> &SomeClass::handleReply); Does the implementation of
> "QNetworkAccessManager::get" guarantee that the "QObject::connect" is
> executed certainly before "finished" signal can be emitted?
You can ask QNR if it is finished()
--
Best Regards
Reinhardt Behm
More information about the Interest
mailing list