qnetworkaccessmanager

Uploading a file using post() method of QNetworkAccessManager

喜欢而已 提交于 2019-12-21 10:56:11
问题 I'm having some trouble with a Qt application; specifically with the QNetworkAccessManager class. I'm attempting to perform a simple HTTP upload of a binary file using the post() method of the QNetworkAccessManager. The documentation states that I can give a pointer to a QIODevice to post(), and that the class will transmit the data found in the QIODevice. This suggests to me that I ought to be able to give post() a pointer to a QFile. For example: QFile compressedFile("temp"); compressedFile

How can i Post the data in QtCreator?

半世苍凉 提交于 2019-12-20 06:33:36
问题 Here is my code of Qt creator to send the data to PHP server and get the response. QNetworkAccessManager *manager = new QNetworkAccessManager(this); QNetworkAccessManager::connect(manager, SIGNAL(finished(QNetworkReply*)),this , SLOT(replyFinished(QNetworkReply*))); QNetworkRequest *request = new QNetworkRequest(QUrl("http://68.169.55.41/fss/verifylogindetails.php")); QByteArray postData =" {\"estate_id\":\"hsr\",\"emp_pin\":1234,\"emp_id\":\"santhosh\"}"; request->setRawHeader( "User-Agent"

Uploading files using Qt QNetworkRequest

不羁岁月 提交于 2019-12-19 17:11:41
问题 I've been having some issues trying to upload files to a server using QNetworkRequest. I've been using this link (http://qt-project.org/forums/viewthread/11361) mostly as a template, but am still getting POST errors (203 to be specific). Here is what I have so far. void MainWindow::processFile(){ QByteArray postData; //Look below for buildUploadString() function postData = mReport->buildUploadString(); QUrl mResultsURL = QUrl("http://" + VariableManager::getInstance()->getServerIP() + "

Uploading files using Qt QNetworkRequest

梦想与她 提交于 2019-12-19 17:05:10
问题 I've been having some issues trying to upload files to a server using QNetworkRequest. I've been using this link (http://qt-project.org/forums/viewthread/11361) mostly as a template, but am still getting POST errors (203 to be specific). Here is what I have so far. void MainWindow::processFile(){ QByteArray postData; //Look below for buildUploadString() function postData = mReport->buildUploadString(); QUrl mResultsURL = QUrl("http://" + VariableManager::getInstance()->getServerIP() + "

Uploading files using Qt QNetworkRequest

匆匆过客 提交于 2019-12-19 17:05:01
问题 I've been having some issues trying to upload files to a server using QNetworkRequest. I've been using this link (http://qt-project.org/forums/viewthread/11361) mostly as a template, but am still getting POST errors (203 to be specific). Here is what I have so far. void MainWindow::processFile(){ QByteArray postData; //Look below for buildUploadString() function postData = mReport->buildUploadString(); QUrl mResultsURL = QUrl("http://" + VariableManager::getInstance()->getServerIP() + "

how can I read the data sent from the server in a variable of type QNetWorkReply?

坚强是说给别人听的谎言 提交于 2019-12-19 11:45:07
问题 I have used this code to sent the user name and a password to the server using POST Method. This returns me a reply,So how can I access the reply variable in the way that i can read the data sent from the server back to me ?? Used Code: void MainWindow::post(QString name, QString password) { QUrl serviceUrl = QUrl("http://lascivio.co/mobile/post.php"); QByteArray postData; QString s = "param1="+name+"&"; postData.append(s); s = "param2=" +password; postData.append(s); QNetworkAccessManager

QNetworkReply and QNetworkAccessManager timeout in http request

孤街醉人 提交于 2019-12-18 13:01:29
问题 How do I setup a timeout when I do an http request? I have this code: { QNetworkRequest request; request.setUrl(QUrl("http://www.foo.com")); request.setRawHeader("User-Agent", USER_AGENT.toUtf8()); request.setRawHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); request.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); request.setRawHeader("Accept-Language", "en-us,en;q=0.5"); request.setRawHeader("Connection", "Keep-Alive"); reply = m

QNetworkAccessManager get/post from different thread possible?

孤人 提交于 2019-12-18 08:55:15
问题 I have a single QNetworkAccessManager object (as Qt docs recommend). However, I need to obtain a request from another thread, i.e. not the thread created the QNetworkAccessManager object. This questions has two aspects: As the functions ( get , post ... ) are not marked threadsafe I assume that I need to use a lock before calling them. But even if I make sure there are no 2 threads calling in parallel, issues could arise: So it could happen a QObject parent child relationship is set, but from

QNetworkReply wait for finished

会有一股神秘感。 提交于 2019-12-18 03:22:12
问题 I am using Qt 4.6.3 and the following not-working code QStringList userInfo; QNetworkRequest netRequest(QUrl("http://api.stackoverflow.com/1.1/users/587532")); QNetworkReply *netReply = netman->get(netRequest); // from here onwards not working netReply->waitForReadyRead(-1); if (netReply->isFinished()==true) {userInfo << do sth to reply;} return userInfo; as this function returns an empty QStringList, the app crashes. How to wait until the request has finished and then process the reply

Alternative for QNetworkAccessManager

陌路散爱 提交于 2019-12-13 16:11:50
问题 I am drawing map in BB10. The map is divided into tiles. At start user gives a longitude, latitude and zoom level and the map is shown at that co-ordinate. I get a single tile by doing a http request with QNetworkAccessManager. At first 7x5 tiles are downloaded. But the problem is when user starts panning in the screen really fast and continues to do so for sometimes then after user stopped panning the tiles are downloaded with a big delay. Each time user does panning some new tiles are