PDA

View Full Version : Qhttp several downloads



cae
29th November 2009, 10:59
hi, i have a program that connects with an ip-cam, on this kind of cam, i can order it to go to some predefinied positions, tanke pictures, or videos, but i have one problem combining all these.

thanks to qhttp and signals, i can send the order to move to one position, and when i recive the requestfinished, i send the order to take a picture, and when that one finishes make another move... and so on, i have a list of activities to do.

void TEjecutor::httpRequestFinished(int id, bool error)
{

Sleep(1500);
if (id==httpMove)
{
// QMessageBox msgBox;
// msgBox.setText(QObject::tr("Move"));
// msgBox.exec();
Sleep(1500);
this->takePicture();
}
else if (this->lista.seekFile(id))
{

this->list.closeFile(id);
// QMessageBox msgBox;
// msgBox.setText(QObject::tr("Download %1").arg(id));
// msgBox.exec();
Sleep(1500);
this->goToPosition();
}

As you can see, when i recive the httpMove, means that the movement its made, so i take the picture, which creates a file and a connection, and goToPosition takes the next target from a list, and makes it



void TEjecutor::takePicture()
{
http->setHost(ip);
http->setUser(user,pass);
int id=http->get(order,file);
this->list.add(file,id);

void TEjecutor:: goToPosition(QString ip, QString user, QString pass, QString destino)
.
.
.
http->setHost(ip);
http->setUser(user,pass);
httpMovimientos = http->get(QString("http://%1/axis-cgi/com/ptz.cgi?gotoserverpresetname=%2").arg(ip).arg(destino));




As you can see at httpRequestFinished i have some QBoxMessage, the fact is that if i run the application with those QBoxes, it'll work perfectly, but if i comment them, the files that i create will remain empty... but i have to make it work without them.
How is this possible? i tryed writing some sleep() functions on the same place as Qboxes were... but it didnt work!!!!


I'm on Windows and Qt 4.5.3

cae
29th November 2009, 20:11
I finally found the solution (not the problem).

I created 2 Qhttp connections, one for the moves and other one for downloading the images.... and it works!!

mgoetz
30th November 2009, 11:04
Just a small note:
For 4.6 you should move to QNetworkAccessManager. More performance and hopefully less bugs.