qtfunctionpointerssignals

Can signals be parameters in Qt?


A function: void function(ObjectName obj, Signal), ObjectName is a class type and obj is an instance. The question is that can the second parameter be a signal which defined in class ObjectName. That means can I use the signal as a normal member function pointer?


Solution

  • Of course! Think about it — QObject::connect() is a function that takes both signals and slots as parameters. Check out its documentation for the various ways this can be implemented.