PDA

View Full Version : Using new Qt Signal Slot connection for QtService framework classes



aamer4yu
5th December 2013, 08:19
I would like to know how to use new Qt Signals and Slots with classes of QtService Framework
The new syntax is of the type -

QObject::connect(&a, &Counter::valueChanged,&b, &Counter::setValue);

This provides compile time checks. So far good.

Now in Qt Service framework, we get an object of service via

QObject * QServiceManager::loadInterface ( const QServiceInterfaceDescriptor & descriptor, QServiceContext * context = 0, QAbstractSecuritySession * session = 0 )
This returns a pointer to QObject. Now we are expected to connect certain signals from the service like "errorUnrecoverableIPCFault".
Now we have a pointer of QObject, and the actual service object may be of any type. Now how can I used the new syntax something like -


connect(pServiceObject,&QObject::errorUnrecoverableIPCFault,this,&MyClass::onErrorUnrecoverableIPCFault);

I cannot use the above format since QObject doesnt have signal errorUnrecoverableIPCFault
The signal is emitted from somewhere within Qt Service framework, and is also not part of my Service class implementation.


So my question is how to use new format of Signal Slots in such cases ??

anda_skoa
5th December 2013, 10:19
The compile time checked signal/slot obviously needs type information, i.e. the compiler needs to know the type of the object in order to check for method availability.

So you either provide that, i.e. make sure that pServiceObject is at least casted to the interface containing errorUnrecoverableIPCFault() and provide that interface's class name when passing the member function pointer.

Cheers,
_