My scenario is this:

I have a sync thread that needs to read from a database and sends data to a 
server. The server response can be  very large. The sync thread should process 
them. I somehow fail to seem how I could decouple the background thread from 
the network stuff.






Von: Konrad Rosenbaum
Gesendet: ‎Mittwoch‎, ‎29‎. ‎Januar‎ ‎2014 ‎18‎:‎24
An: interest@qt-project.org





On Wednesday, Wednesday 29 January 2014 at 16:27, Philipp Kursawe wrote:

> I have the following problem. I want to have only one QNAM in the (heavily

> plugin based) app.

> 

> So I create one QNAM in the main thread when the app starts and assign it

> to the qApp->setProperty("qnam").

> 

> Now I have several threads that can run in the background and once in a

> while need network access and process the (big) results. Naturally the

> processing of this big data set cannot be done on the main thread, that

> also runs the UI. So I have to use threads to keep the UI fast and

> responsive.

 

If your only reason for using threads is to offload processing of the results, 
you might as well do all the network handling in the main thread and just 
offload the processing of the results once you have them.

 

> But it seems to be impossible to connect a slot from a thread to a signal

> of the QNAM created QNetworkReply object.

 

This should not be a problem. You can connect signals and slots across thread 
boundaries without problems. What specifically is going wrong for you? Do you 
have trouble handing over the QNetworkReply?

 

BTW: if you have to handle authenticationRequired or sslErrors signals across 
threads you need to use a Qt:BlockingConnection.

 

 

 

 

Konrad
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to