POST-Request with QT5
c++, http-post, qt, qt5
Solution
Did you try `QNetworkAccessManager`?
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
manager->post(QNetworkRequest(QUrl("http://example.com/yourscript.php")), data);
`data` is a `QByteArray` that you can generate from a QString if needed.
Problem
I'm new to Qt and have some difficulties regarding a post request to a PHP file and reading the response. Everything I found about how to implement a POST request in Qt 5 is somehow outdated (Qt 4.x) and does not work properly, OR doesn't help me because of some lack of knowledge. For example, the php file looks like this: ``` <?php // read param1 $value = $_POST['param1']; // Do some stuff here // return some text echo $value; ?> ``` All I want to do is this: - Make a post-request and deliver some data (param1, value1) - Read the return-value of the PHP file Is there a small example of c++-code, how to implement this task with QT5?