[solved] Qt Signal/Slots in one class but emitted from different threads
-
You can also use the connection type in your connect statement, if you need.
It depends on what you want to do in response to those signals though. You can not trigger anything that modifies the GUI from another tread than the GUI thread. That can only be done using queued connections, never with direct method calls or direct connections (amount to pretty much the same thing).
-
[quote author="Gerolf" date="1304063870"]You could go a bit another way:
use
@
QMetaObject::invokeMethod(this, "foo", Qt::QueuedConnection);
@There you can also post parameters
@
QMetaObject::invokeMethod(this, "foo", Qt::BlockingQueuedConnection, Q_ARG(<param type>, param));
@
[/quote]That is working, thank you.
-
[quote author="Gerolf" date="1304067659"]If you then emit inside your class, it did not work? strange... should do logically the same as QMetaObject::invokeMethod[/quote]
That was the first thing i tried, from what i read i thought it should work. But the code never reached the slot function
-
[quote author="bazz-dee" date="1304068700"]
[quote author="Gerolf" date="1304067659"]If you then emit inside your class, it did not work? strange... should do logically the same as QMetaObject::invokeMethod[/quote]That was the first thing i tried, from what i read i thought it should work. But the code never reached the slot function[/quote]
perhaps, the code was wrong? Did you add the parameter types inmj signals and also the brackets? param,eter trypes in the slot ?
@
connect(this, SIGNAL(xyz(type1, type2)), this SLOT(xyz()));
@