QWidget
class is a subclass of QObject
which has copy and assignment operations disabled using the Q_DISABLE_COPY
guard macro. When you inherit from QObject
(or any derived class), the copy constructor or assignment operator you define tries to access base class's counter parts, but they are private in QObject
and can not be accessed. This is by design.
As a side effect, object of classes that inherit from QObject
can not be stored in STL or Qt containers (vector, list, etc). Only pointers or references can be stored. Because getting/setting object requires copying using the copy constructor, which is not possible.
If you need both to inherit from QWidget
and overloading operator=
and/or copy constructor
, you can achieve by adding explicit methods for these tasks like isEqual
or clone
(though cloning QObject
is not a good idea).