[Qt-interest] QT Plugin with signals

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Mar 31 15:39:41 CEST 2010


On Wed, Mar 31, 2010 at 6:58 PM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 31.03.10 18:38:28, Mandeep Sandhu wrote:
>> I'm writing a QT Plugin which needs to emit certain signals.
>>
>> Where should the signals be declared? In the interface or in the
>> implementation class?
>>
>> I'm currently declaring the signal in the _implementation_ class (from
>> where it's actually emitted). The implementation class inherits
>> QObject.
>>
>> In the application I load the plugin using the QPluginLoader class.
>> The app only has a reference of the plugin interface since only that
>> is visible to it. When I try to connect the signal emitted by the
>> implementation class to an apps slot, the compiler complains since
>> connect expects a QObject*  whereas my interface class is not a
>> subclass of QObject.
>>
>> Whats the correct way of going about it?
>
> If you want real interfaces that you can mix, then you'll have to expose
> the plugin class somehow also as a QObject* for the connect to work. The
> other option would be making your interface "fat" and let the interface
> inherit from QObject..

Yup. Thats what I did now. It's working.

I've inherited QObject in my interface class, though the signals still
being emitted by the implementation class.

Thanks,
-mandeep

>
> Andreas
>
> --
> Long life is in store for you.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list