QPointer uses mechanisms of QObject. He needed convert your type to QObject. I think, QPointer uses destroyed() signal from QObject.And why should i need to include the file with class B in the file where i write class X?
QPointer uses mechanisms of QObject. He needed convert your type to QObject. I think, QPointer uses destroyed() signal from QObject.And why should i need to include the file with class B in the file where i write class X?
pkj (6th September 2011)
#include "b.h" did the trick. Thanks. What I don't get, however, was why was it necessary. Going through qpointer code, I saw they store it as QObject*. Now QObject was being include'd. QPointer class is only interested in the QObject part of the class B. I think it should have gone through??
No, QPointer doesn't use destroyed(), there is a dedicated mechanism embedded in QObject for handling QPointer.
Somewhere in your code you have the following line:
which informs the compiler (forward declares the B class) that there exists a class called "B". It lets you use pointers to B in your code (as the size of pointer is fixed) without a full declaration of the B class (which is needed to use objects and methods as the compiler needs to know the size of the object and offset of methods in the object). But it doesn't inform the compiler that B is derived from QObject. Without that knowledge the compiler cannot allow a cast from B to QObject.
pkj (7th September 2011)
Bookmarks