Reputation: 1629
Im trying to send parameter to a Qthread that is not the main thread. i have this object in my main thread and i want to send it to another thread:
q = Queue()
I want so send q
to this thread:
class Sender(QtCore.QThread):
def __init__(self,q):
super(Sender,self).__init__()
self.q=q
def run(self):
while True:
try: line = q.get_nowait()
# or q.get(timeout=.1)
except Empty:
pass
else:
self.emit(QtCore.SIGNAL('tri()'))
Im trying this:
class Sender(QtCore.QThread):
def __init__(self,q):
super(Sender,self).__init__()
self.q=q
self.sender= Sender(q)
But im getting this error:
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)
How can i do this? Please help!
Upvotes: 1
Views: 3589
Reputation: 92569
There is no problem with your QThread
subclass, and how you are setting it up to pass a Queue
object. Though I do also recommend passing and setting an optional parent as the second parameter.
What you are mostly likely running into is you are passing objects that perform QtGui operations (drawing related) into your thread. If that is the case, you cannot call any QtGui drawing related methods. They all must be performed in the main thread. Do any data processing in other threads and then emit signals for the main thread to do widget updates.
Look for what you are sending into the queue, and specifically what you are doing with it inside of your thread, as a cue to the source of the error. Somewhere, you are doing something with a QTextCursor
, which is trying to trigger and queue up a paint event.
Upvotes: 3