Hi Forum,
Suppose that i define the following class as the subclass of QObject for smarter memory management:
{
Q_OBJECT
.....................
.....................
};
class Shader : public QObject
{
Q_OBJECT
.....................
.....................
};
To copy to clipboard, switch view to plain text mode
Then inside the another class definition i declare a pointer of the above type (composite pattern) as follows:
Shader *shade;
Shader *shade;
To copy to clipboard, switch view to plain text mode
And inside the source of the class definition i allocate memory on the heap. Just because i inherited from QObject , will the memory pointed by shade be de-allocated by Qt ?
If this is so , then what is the point of having the following declaration instead?:
QPointer<Shader> shade;
QPointer<Shader> shade;
To copy to clipboard, switch view to plain text mode
or
QSharedPointer<Shader> shade;
QSharedPointer<Shader> shade;
To copy to clipboard, switch view to plain text mode
or
QScopedPointer<Shader> shade;
QScopedPointer<Shader> shade;
To copy to clipboard, switch view to plain text mode
There are few more in the documentation. Lets understand the above first.
Some explanation with code snippet would be very helpful.
Thanks
Bookmarks