Update function with timer
Unsolved
General and Desktop
-
Your code snippet shows a QMainWindow based class using a designer based UI with a slot connected to a QPushButton named pushButton.
That doesn't look like a console application code.
-
Then why are you using GUI classes ?
-
wrote on 28 Feb 2016, 13:25 last edited by
just sample above codes
-
wrote on 28 Feb 2016, 13:26 last edited by
#include "networkprocess.h" NetworkProcess::NetworkProcess(QObject *parent) : QObject(parent) { nam = new QNetworkAccessManager(); timer=new QTimer(this); url2.setUrl("ftp://myserver"); url2.setPassword("xxx"); url2.setUserName("xxx"); url2.setPort(21); req.setUrl(url2); reply = nam->get(req); connect(reply, SIGNAL(readyRead()),this, SLOT(downloadReadyRead())); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); timer->setInterval(500); timer->start(); connect(timer,SIGNAL(timeout()),this,SLOT(updatet())); } void NetworkProcess::updatet() { updatereply=reply; } void NetworkProcess::downloadReadyRead() { if(updatereply->error() == QNetworkReply::NoError){ buf = updatereply->readAll(); if(buf=="Kapat") { qDebug()<<"tako"; } if(buf=="Ac") { qDebug()<<"vural"; } } } void NetworkProcess::requestFinished() { }
this is
-
That update function doesn't really make sense. The reply is automatically updated while the request is being processed.
Why not use the downloadProgress signal if you want information about the downloading state of your query ?
On a side note there's the QtFTP module that you can use to access a FTP server.
-
wrote on 29 Feb 2016, 14:02 last edited by
I used QT5.5 . There is no qtftp.
-
Please, take the time to do a bit of search: http://code.qt.io/cgit/qt/qtftp.git/
-
git clone https://code.qt.io/qt/qtftp.git cd qtftp qmake make make install
15/15