You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

BeS

Beginner

  • "BeS" is male
  • "BeS" started this thread

Posts: 26

Location: Germany

  • Send private message

1

Saturday, August 6th 2011, 5:57pm

Synchronous KIO::TransferJob

Hi,
I want to execute a simple HTTP get request with KIO::TransferJob.

At the moment I' using a slot to get the result:

Source code

1
2
KIO::TransferJob *job = KIO::get(KUrl(url));
connect (job, SIGNAL(  data(KIO::Job *, const QByteArray & )), this, SLOT(dataIsHere(KIO::Job *,const QByteArray &)));


But I need a way to execute the job synchronous so that the program only continues after I get the result.

I already tried something like this:

Source code

1
2
3
4
KIO::TransferJob *job = KIO::get(KUrl(url));
QEventLoop loop;
QObject::connect(reply, SIGNAL(data(KIO::Job *, const QByteArray & )), &loop, SLOT(quit()));
loop.exec();


But than I don't know how to access the result ( the QByteArray) of the job.

Can you help me to execute the KIO::TransferJob synchronously?

Thanks!
If art interprets our dreams, the computer execute them in the guise of programs!

Similar threads