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 moved code to dlls and now qobject_cast<> works....
Looking for 0xf39b050 Globe::Channel on Globe::ComoChannel(0x4210270,
name = "Channel") Globe::ComoChannel(0x4210270, name = "Channel")
0xf04c018 Globe::ComoChannel
0xf39b050 Globe::Channel <-
0x663fc44c QObject
Thank you for the explanations...
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest