[Interest] QNetwork classes for submitting google forms

Nicholas Yue yue.nicholas at gmail.com
Sat Jun 12 00:53:29 CEST 2021


```

int main()

{


    QUrlQuery postData;

    postData.addQueryItem("emailAddress", "abc.xyz at gmail.com");

    postData.addQueryItem("entry.2020959411", "Qt Query");


    QUrl serviceUrl("https://docs.google.com/forms/d/152CTd4VY9pRvLfeACOf6SmmtFAp1CL750Sx72Rh6HJ8/formResponse");

    QNetworkRequest request(serviceUrl);



    QNetworkAccessManager networkManager;

    bool gotResponse = false;


    QObject::connect(&networkManager, &QNetworkAccessManager::finished,

                     [&gotResponse](QNetworkReply *reply) {

        int status = reply->attribute(

                    QNetworkRequest::HttpStatusCodeAttribute).toInt();

        qDebug() << status;

        //  etc....

        gotResponse = true;

    });


    networkManager.post(request,

                        postData.toString(QUrl::FullyEncoded).toUtf8());


    while (!gotResponse) {

        QThread::sleep(1); // or whatever sleep method, just waiting
for a response.

        qDebug() << "Slept 1 second";

    }


    return 0;


}

```


It just sits there, I get the regular print out about 'Slept 1
second', other than that, it does not seems to be working


On Fri, 11 Jun 2021 at 14:18, Max Paperno <max-l at wdg.us> wrote:

>
> > QObject::connect(&networkManager, &networkManager::finished, ...
>
> Whoops, should really be
> QObject::connect(&networkManager, &QNetworkAccessManager::finished, ...
>
> -Max
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>


-- 
Nicholas Yue
Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
Custom Dev - C++ porting, OSX, Linux, Windows
http://au.linkedin.com/in/nicholasyue
https://vimeo.com/channels/naiadtools
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210611/8c095429/attachment-0001.html>


More information about the Interest mailing list