[Qt-interest] qobject_cast<>() and objects from dynamically loaded libraries
Dmitry Nezhevenko
dion at inhex.net
Wed Jan 21 13:51:03 CET 2009
Hi guys.
I'm experiencing strange behaviour of QObject cast. Basically I've code
like:
class Base: public QWidget
{
Q_OBJECT
};
class SomeImpl: public Base
{
Q_OBJECT
};
On Win32 I have some function DLL-exported that returns pointer to QWidget:
QWidget *getWidget();
After loading library (LoadLibrary && GetProcAddress) and calling to
getWidget() I'm trying to cast returned pointer to Base:
Base *b = qobject_cast<Base *>(w);
And b = 0 here. I'm sure that w is correct pointer. For example I can do:
QString className = w->metaObject()->className();
And className became "SomeImpl". Also debugger shows that w is instance of SomeImpl
and contains Base.
Also dynamic_cast works as expected. Any ideas why qobject_cast returns
zero?
PS. Qt 4.4.3, MSVC2005
--
WBR, Dmitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090121/0c245b82/attachment.bin
More information about the Qt-interest-old
mailing list