Friday, 15 July 2011

How can I find the source of a Qt5 signal during gdb session? -



How can I find the source of a Qt5 signal during gdb session? -

i have set break-point on slot method , started gdb debug qt5 application. know in code slot gets called (via qt5 signal system).

my naive approach ends in suspension of programme @ break-point, stack-trace qt5 internals no clue part of programme sent signal slot (or weather queued or direct invocation:

is @ possible? how?

thanks!

updated

the time won't see signal caller in stack backtrace when connection queued.

for direct connections should see this:

0 receiver::baz() <-- slot function received signal 1 receiver::qt_static_metacall() 2 qmetaobject::activate() 3 sender::bar() <-- function name of signal 4 sender::foo() <-- function called emit 5 qwidget::event() ...

for queued connections, situation more complicated. can add together next slot:

qstring __sender__ = sender()->metaobject()->classname();

this give class name of object, had sent signal. can create macro , sprinkle in code.

alternatively, if have multiple objects of same class , need know 1 had sent signal, can utilize sender() function , compare object address, etc.

gdb qt5 signals-slots

No comments:

Post a Comment