[Qt-interest] need some QThreading help
Jason H
scorp1us at yahoo.com
Fri Jul 9 21:05:36 CEST 2010
You take it int descriptor from the incommingConnection, assign it as a member
of the thread class, then int he run() you use setSocketDescriptor() on the
socket.
________________________________
From: Oluwafemi Ade <oamaximpact at gmail.com>
To: qt-interest at trolltech.com
Sent: Fri, July 9, 2010 11:25:06 AM
Subject: [Qt-interest] need some QThreading help
Hello everyone......I'm building a multithreaded client-server app, and I seem
not to be getting through with my QThread subclass,
the server's main thread listens for incoming conns. and spawns a new QThread
subclass everytime one arrives...........
however, run-time complains that it can't create children in a thread different
from the parent thread (i thinks its talking about my QThread subclass
"ServerThread"
i.e in inComingConnection()
{
I created a ServerThread *ptr on stack.............
I also created a QTcpSocket *ptr too...............
connect(readyRead) here to a slot in ServerThread..............
and somehow find a way to move them both out to the new thread...............
the ServerThread constr. takes a QTcpSocket *ptr as arg, so I pass the one I
allocated............
the ServerThread has a public func that takes a ServerThread *ptr so I passed
the ServerThread I allocated on the Stack........
finally I connected a SIGNAL in serverThread that's emitted in run(), (before
exec() in run() ) that passes the (threadID *, QTcpSocket *ptr, ServerThread
*ptr) to a slot in my main thread.........
(call thread->start())................................
from the slot in my main thread I moved the socket and thread to the given
thread to be both there before exec is reached..............
(they got there after exec() )...........
}
all to no avail................
pls help
( I did this to circumvent the problem of not being able to create children in a
different thread..............
however the new problem that emerged is "...............
QObject::moveToThread: Current thread (0x8277490) is not the object's thread
(0x83dd408).
Cannot move to target thread (0x83dd408)
QObject::moveToThread: Current thread (0x8277490) is not the object's thread
(0x83dd408).
Cannot move to target thread (0x83dd408)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100709/2a44d0fb/attachment.html
More information about the Qt-interest-old
mailing list