I have a derived QList<MyClass>
, with a member QMutex
.
class WaypointList : public QList<Waypoint> {
private:
mutable QMutex _mutex; /*!< Mutex for thread safety */
..
} // HERE COMPILE ERROR, in this line
Compiling, I get C2248: 'QMutex::operator =' : cannot access private member declared in class 'QMutex'
The reason is that QMutex
is not copyable (Q_DISABLE_COPY
, related SO Question). Here it is recommended to make the member a pointer. Is that the best way to do it?
Remarks:
- When I use
QMutex _mutex
in a derivedQ_OBJECT
class, it works fine. Any idea why I get the error here and not with aQ_OBJECT
class? - In other languages I'd declare the member as transient. Actually I do not want to have it copied. Is there a declaration for just ignoring it?
- Or is writing an assignment / copy operator the better approach?