[Interest] qobject_cast
Igor Mironchik
igor.mironchik at gmail.com
Thu Apr 20 11:42:28 CEST 2017
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...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170420/99a46e05/attachment.html>
More information about the Interest
mailing list