[SOLVED] error: 'QObject::QObject(const QObject&)' is private
-
Hi all,
i have this situation:
@
#include <QObject>class MeteoLocale: public QObject
{
Q_OBJECTpublic:
MeteoLocale();
virtual ~MeteoLocale();QList<MeteoLocale> underList;
}@
and this is the error that return:
error: 'QObject::QObject(const QObject&)' is private
exist a some kind of metod to do this?
regard
-
The copy constructor is private, thus you have to use pointers in your list.
@
QList<MeteoLocale *>
@ -
but i need to set value not pointer...
-
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>).
-
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