QObject explicit constructing and QSharedData
Hi,
I want to create the class which extends QObject and support QSharedData. However I am given with the compiler warning as
follow:
Code:
ostrzeżenie:base class 'class QObject' should be explicitly initialized in the copy constructor [-Wextra]
.
Therefore I am thinking of this approach being valid or invalid, because my intention is to have the class which can be initialized with parent from any other class but with QSharedData support. How can I get this without causing compiler to complain ?
Re: QObject explicit constructing and QSharedData
It would help to see the class header and source.
Cheers,
_
Re: QObject explicit constructing and QSharedData
Code:
class QubiconModelData;
class QubiconModel
: public QObject {public:
QubiconModel();
QubiconModel(const QubiconModel &);
QubiconModel &operator=(const QubiconModel &);
~QubiconModel();
private:
QExplicitlySharedDataPointer<QubiconModelData> data;
};
here is the header...I didn't wrote it myself, this particular part of code has been auto-generated via QtCreator new class wizard.
Re: QObject explicit constructing and QSharedData
It won't work. QObject instances can't be copied. Why do you want to derive that class from QObject?
Re: QObject explicit constructing and QSharedData
Wanted to have out-of-the-box support for automatic objects deallocation...however it seems that since it is not possible I will just take care of it myself :p
Re: QObject explicit constructing and QSharedData
Quote:
Originally Posted by
kornicameister
Wanted to have out-of-the-box support for automatic objects deallocation..
I don't see how that's related. If you have a value-based class that contains a shared data pointer then you allocate such objects on the stack and you don't need any special automatic object deallocation because deallocation is automatic by the definition. If you allocate such objects on the heap, then you usually don't need them to be based around shared data and even if you do, you can use an external smart pointer to manage such object.
Re: QObject explicit constructing and QSharedData
That's some useful explanation...thank you :)