Hi
I wanted to replace the signals and slots in my application to callback functions.
example QObject::connect(c,SIGNAL(sendSignal2(void *)), c ,SLOT(Some_Function(void *)));
how to do the same functionality with callback... how to do this?
Hi
I wanted to replace the signals and slots in my application to callback functions.
example QObject::connect(c,SIGNAL(sendSignal2(void *)), c ,SLOT(Some_Function(void *)));
how to do the same functionality with callback... how to do this?
Why would you want to replace the signal/slot mechanism with callbacks?
just wanted to check wether callbacks are faster than signals and slots.. as in my application they are taking much of a time..
is callback is faster than signals/slots? anybody have tested it? i wanted to test the same.. how to replace the code please help
Last edited by meena; 20th August 2010 at 11:31.
Dont think they can be slow.. how much time are they taking ??. as in my application they are taking much of a time..
If you want to use callbacks,, it will be your design. I dont think Qt does that for you.
They are taking around 550 mili seconds ... i understand that qt does not have anything for callbacks, but i wanted a help to replace those above statements.
In a way, signals/slots are a callback (direct connection), unless its not possible, in which case they use events (queued connection).
If you want to use callbacks you will have to implement the functionality yourself (eg, pass the functinos pointers to your relevent objects)
The real reason Qt got off the ground in the first place is because the whole callback issue got ugly in other frameworks.
By reintroducing them you'd destroy the thing Qt is best at.
Signals and slots are marginally slower than callbacks, but they are typesafe.
500 ms = half a second? That cannot be true, please measure again. The emit statement is just a function call, so I guess you are timing your own function.
As someone as pointed out, when you connect() the signals you can pass "Qt::QueuedConnection" to speed up the emit (the function will be called later by the event loop)
Connect: http://doc.trolltech.com/4.6/qobject.html#connect
Qt::QueuedConnection: http://doc.trolltech.com/4.6/qt.html...ctionType-enum
The difference in execution speed between signals and slots is measured in a handful of milliseconds at most. In other words, it will be unnoticeable in all but the most pathological programs.
Rather than thrash around trying to replace an elegant software system with one that is error prone, buggy and semantically ugly - on a good day - and which is almost certainly not causing a significant slowdown - try running your application through a profiler to determine where it is spending it's time, and why.
thanks everybody for replying, can u suggest/give some profiling tool and how to use them
Last edited by meena; 21st August 2010 at 09:11.
That depends on your processor, some only work on Intel, some only on AMD, and some on both.
Intel used to provide a free one, but I think it's now commercial, called VTune.
AMD provide CodeAnalyst, which I think is still free.
then there's lot of third party ones which cost varying amounts.
If your happy with CLI, Visual studio comes with a free one, as does GCC.
Bookmarks