[Interest] QTcpSocket from QTcpServer

Thiago Macieira thiago.macieira at intel.com
Mon Jul 16 13:56:45 CEST 2012


On segunda-feira, 16 de julho de 2012 13.23.01, Lucas.Betschart at crypto.ch 
wrote:
> I got a thread access problem with QTcpSocket.

[cut the description that doesn't talk about QThread]

> The QTcpServer documentation says:
> Note: The returned QTcpSocket object cannot be used from another thread. If
> you want to use an incoming connection from another thread, you need to
> override incomingConnection().
> 
> But why does it work in one (slot $B) of them but not in the other (slot $A)
> ?

Because clearly something is different.

You think you have a threading problem and the warning you get is a sure sign 
of that. Yet your description does not mention QThread, or even threads, at 
all. How do you want us to help you solve your problem related to threads?

Some sample code would be most welcome for us to understand what's going on.

In the meantime:
1) do NOT create slots in a class derived from QThread. Just don't. I won't 
help you if you post code that does that. If you have that, you'll need to fix 
it before posting the code.

2) QTcpSocket and QTcpServer do not require threads to work. So please post 
your reasoning for using threads along with your code.

3) make sure you understand how automatic connections work in Qt and which 
thread each object in your code actually lives in (i.e., which thread the 
slots will be called in).
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120716/f37627d6/attachment.sig>


More information about the Interest mailing list