Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] error: 'QObject::QObject(const QObject&)' is private
i have this situation:
class MeteoLocale: public QObject
and this is the error that return:
error: 'QObject::QObject(const QObject&)' is private
exist a some kind of metod to do this?
steno last edited by
The copy constructor is private, thus you have to use pointers in your list.
but i need to set value not pointer...
lgeyer last edited by
A QObject and it derivations are non-copyable (more specifically non-copy-constructible and non-assignable). The container classes, like QList, require a copyable type.
Therefore you cannot create a QList of QObject objects. You will have to create a QList of pointer to QObject (<code>QList<MeteoaLocale *> underList</code>).
Adrien Leravat last edited by
To complete Lukas Geyer answer, the reason why QObject cannot be copied nor assigned is because they are considered individuals: they can have a name, a parent, children and connections. As copying these all would not make sense, it was made impossible.
Just allocate your objects with 'new' and fill your list with the returned pointers
Tanks to all guy, to solve i have decide to remove the QObject ensension and for interact whit QML i create another object whit the same property but extend QObject.
Tnx to all