Just to be clear I understand:
Are you looking for signals/slots with return values other than void, is that it?
Just to be clear I understand:
Are you looking for signals/slots with return values other than void, is that it?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Yes, it's the slots returning values.
I can't test at the moment, but its possible that slots actually can be defined with a return value - however, when used as a slot, how do you want to get the value?
Since you are not calling the slot directly, but only invoke its call (as in emit a signal), and not by the object invoking emitting the signal - so what good would it be for you if the slot is retuning a value - you can't get to that value any way (in the object that emitted the signal)!
Or in other words, you can get the return value only there where the slot is really called - namely in the MetaObject but there you probably wont know what to do with the return value...
Try defining a slot that returns a value and see if the connection works.
If it does, you are still stuck with my question - when and how do you want to get the return value from the slot?
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Have you seen QFuture and QtConcurrent ?
This does exactly what you ask in the thread title.
As I did say, I use QMetaObject::invokeMethod().
It is possible to get return value (see Q_RETURN_ARG macro), but only in Qt:irectConnection, i.e. slot will be running in the same thread as a caller object. But I need it running in another thread. It can be achieved only in queued connection, in this case invokeMethod() with the Q_RETURN_ARG is useless. But I can write some data in memory passing its pointer as a slot argument (using Qt::BlockingQueuedConnection, of course). But I thought there is another way similar to invokeMethod() with Q_RETURN_ARG.
int someValue() is more beautiful than void giveMeSomeValue(int *where).
Added after 11 minutes:
Can I select a particular QThread from global pool?
Last edited by elk; 9th February 2011 at 13:37.
Yes, connection to a slot returning value works ok.Try defining a slot that returns a value and see if the connection works.
I don't know, why do you need a particular thread to run your code ?Can I select a particular QThread from global pool?
Bookmarks