views:

254

answers:

4

I can imagine that there might be quite a few of them depending on the event, but at the same time, I guess this can be a best way to debug, and an interesting lesson.

Why would I need it? I'm using some custom class based on the QWidget, which does not expand when I de-attach a QDockWidget based in the same window. Knowing what signals are emitted when this dock widget is being de-attached would help me to chose which method I need to overwrite in my custom class.

In other words, I don't want to check every possible signal from the documentation, but just see which signals are emitted when I perform some action in my application.

+4  A: 

You may want to take a look at the QSignalSpy class. I think though you have to connect manually the signal you want to spy.

gregseth
+1  A: 

I don't think this is possible with Qt. You can

  • list all signals of a class using QMetaObject::method and QMetaMethod::methodType;
  • attach one of your own slots to all of those signals;
  • check who invoked a slot using QObject::sender.

But I'm stuck after this. I don't think that, besides the sender, any information can be obtained about how a slot got invoked.

Job
+3  A: 

This isn't possible with any public API.

But, if you put your code into a QTestLib-based unit test, you can run the unit test with -vs to print out every emitted signal.

Intransigent Parsnip