Hi,

If sender() is a Channel*, then qobject_cast should not fail.

Try to add this to your slot, this will print the inheritance list

     qDebug() << "Looking for" << &Channel::staticMetaObject <<
Channel::staticMetaObject.className() << "on" << sender() <<
qobject_cast< Channel* > ( sender() )
     const QMetaObject *mo = sender->metaObject();
    while (mo != nullptr) {
         qDebug() << mo << mo->className() << (mo ==
&Channel::staticMetaObject ? "<-" : "");
         mo = mo->superClass();
     }

This is roughly how QMetaObject::inherits() works. if you get the
"<-", then qobject_cast should work as expected.

I got:

Looking for 0xe6b188 Globe::Channel on Globe::ComoChannel(0x4500270, name = "Channel") QObject(0x0)

0xd49548 Globe::ComoChannel

0xd4f060 Globe::Channel

0x6683c44c QObject


And as I can guess it's because of static linking. I.e. I have static lib where Channel defined. And this lib linking to app and to plugin.


Am I right that I should use dynamic libs?


_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to