qnetworkaccessmanager

Handling network timeout in Qt

天大地大妈咪最大 提交于 2019-12-04 09:10:27
When dealing with QNetworkReply , it is prescribed to use timers to abort the connection. Here is my current code: void ImageDownloader::download(QString imgUrl){ this->timeoutTimer = new QTimer(this); this->timeoutTimer->setSingleShot(true); this->timeoutTimer->setInterval(15000); connect(this->timeoutTimer, SIGNAL(timeout()), this, SLOT(timeout())); QUrl requestUrl(imgUrl); QNetworkRequest nwRequest(requestUrl); this->imageNwReply = this->nam->get(nwRequest); connect(imageNwReply,SIGNAL(finished()),this,SLOT(imgDownloaded())); connect(imageNwReply, SIGNAL(downloadProgress(qint64,qint64)),

QT HTTP Post issue when server requires cookies

倾然丶 夕夏残阳落幕 提交于 2019-12-04 05:19:11
I have been trying this whole day with no success. Please help in solving the issue. On googling I found many users had this issue but nowhere I could find a solution. I am trying to do HTTP post in QT C++ & I have already tried doing that in python (My question is not a python question, so Qt pros please help ).. I know, I am somewhere wrong in handling cookies and all, so please help. Please provide probable solutions. In python, code is clean and simple. I have stripped error handling and all extra things to make it simple. url = 'http://www.example.com/' data = 'username=abc&password

QThread ASSERT failure in QMutexLocker: “QMutex pointer is misaligned”,

牧云@^-^@ 提交于 2019-12-04 05:09:21
问题 Im trying to create an uploader that will create new threads and in every thread I have a QNetworkAccessManager. All the uploader threads have a reference to a shared list and will split it by using start and end indexes. The Uploader looks something like this: class FileUploader : public QObject { Q_OBJECT public: explicit FileUploader(QList<FileInfoWrapper> &fileList, const int start = 0, const int offset = 0, QObject *parent = 0); void uploadNext(); QString containerName; private: int

Uploading a file using post() method of QNetworkAccessManager

大城市里の小女人 提交于 2019-12-04 05:09:15
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.open(QIODevice::ReadOnly); netManager.post(QNetworkRequest(QUrl("http://mywebsite.com/upload") ),

QObject: Cannot create children for a parent that is in a different thread

核能气质少年 提交于 2019-12-04 05:02:56
EDIT: I tried doing what you guys told me in comments ... : Citizen * c = new Citizen(this); QThread thread; c->moveToThread(&thread); connect(&thread, SIGNAL(started()), c, SLOT(ProcessActions())); thread.start(); This produces even more errors: QThread: Destroyed while thread is still running ASSERT failure in QThread::setTerminationEnabled(): "Current thread was not started with QThread.", file c:\ndk_buildrepos\qt-desktop\src\corelib\thread\qthread_win.cpp, line 542 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. QObject::killTimers: timers

Howto implement SFTP with Qt/QNetworkAccessManager (C++)

喜夏-厌秋 提交于 2019-12-03 12:16:03
问题 I'm new to Qt and I would like to implement FTP and SFTP support for my software. As I googled I discovered that there doesn't exist a sftp library for Qt but it should be possible with QNetworkAccessManager. I tried then to discover on how to build a custom protocol or something like that but didn't figure out how to do it. Does someone know how I could do that? Thanks, Michael 回答1: There is no support for SFTP in Qt SDK but Qt Creator implements SFTP. I have isolated the library that

How can i Post the data in QtCreator?

青春壹個敷衍的年華 提交于 2019-12-02 12:20:40
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" , "Mozilla Firefox" ); request->setRawHeader( "charset", "utf-8" ); request->setRawHeader( "Connection"

QThread ASSERT failure in QMutexLocker: “QMutex pointer is misaligned”,

隐身守侯 提交于 2019-12-02 04:12:50
Im trying to create an uploader that will create new threads and in every thread I have a QNetworkAccessManager. All the uploader threads have a reference to a shared list and will split it by using start and end indexes. The Uploader looks something like this: class FileUploader : public QObject { Q_OBJECT public: explicit FileUploader(QList<FileInfoWrapper> &fileList, const int start = 0, const int offset = 0, QObject *parent = 0); void uploadNext(); QString containerName; private: int start_, offset_, iterator_; QList<FileInfoWrapper> &fileList_; RestFileUploader *restFileUploader; signals:

QNetworkAccessManager from ThreadPool

孤人 提交于 2019-12-01 19:35:56
问题 A very fundamental question. The documentation mentions that all methods in QNetworkAccessManager are reentrant. If so, is performing a get() method in a QRunnable without locks legal? My code would look something like this: class MyClass: public QRunnable { void run() { ... QNetworkAccessManager nam; QNetworkReply* reply = name.get(request) // No Read-write lock. ... } }; 回答1: From the Qt documentation: [...] a class is said to be reentrant if its member functions can [simultaneously] be

QNetworkAccessManager from ThreadPool

偶尔善良 提交于 2019-12-01 19:10:20
A very fundamental question. The documentation mentions that all methods in QNetworkAccessManager are reentrant. If so, is performing a get() method in a QRunnable without locks legal? My code would look something like this: class MyClass: public QRunnable { void run() { ... QNetworkAccessManager nam; QNetworkReply* reply = name.get(request) // No Read-write lock. ... } }; From the Qt documentation : [...] a class is said to be reentrant if its member functions can [simultaneously] be called safely from multiple threads, as long as each thread uses a different instance of the class. Since you