I have a problem with my object hierarchy. I have child classes "Point", "LineString", ... which inherits the parent class "Geometry".
Now I want to emit signals from the child objects, so I added QObject to the parent class
{
Q_OBJECT
public:
...
}
class Geometry : public QObject
{
Q_OBJECT
public:
Geometry(QString name = QString());
...
}
To copy to clipboard, switch view to plain text mode
On compiling I get the following error:
/usr/include/QtCore/qobject.h:287: error: 'QObject::QObject(const QObject&)' is private
src/geometry.h:31: error: within this context
src/point.h: In copy constructor 'Point::Point(const Point&)':
src/point.h:31: note: synthesized method 'Geometry::Geometry(const Geometry&)' first required here
/usr/include/QtCore/qlist.h: In member function 'void QList<T>::append(const T&) [with T = Point]':
/usr/include/QtCore/qlist.h:419: note: synthesized method 'Point::Point(const Point&)' first required here
/usr/include/QtCore/qobject.h: In member function 'Geometry& Geometry::operator=(const Geometry&)':
src/geometry.h:31: instantiated from 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = Point]'
/usr/include/QtCore/qlist.h:417: instantiated from 'void QList<T>::append(const T&) [with T = Point]'
src/linestring.cpp:68: instantiated from here
/usr/include/QtCore/qobject.h:287: error: 'QObject& QObject::operator=(const QObject&)' is private
src/geometry.h:31: error: within this context
src/point.h: In member function 'Point& Point::operator=(const Point&)':
src/point.h:31: note: synthesized method 'Geometry& Geometry::operator=(const Geometry&)' first required here
/usr/include/QtCore/qlist.h: In member function 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = Point]':
/usr/include/QtCore/qlist.h:332: note: synthesized method 'Point& Point::operator=(const Point&)' first required here
gmake: *** [linestring.o] Error 1
*** Exited with status: 2 ***
/usr/include/QtCore/qobject.h:287: error: 'QObject::QObject(const QObject&)' is private
src/geometry.h:31: error: within this context
src/point.h: In copy constructor 'Point::Point(const Point&)':
src/point.h:31: note: synthesized method 'Geometry::Geometry(const Geometry&)' first required here
/usr/include/QtCore/qlist.h: In member function 'void QList<T>::append(const T&) [with T = Point]':
/usr/include/QtCore/qlist.h:419: note: synthesized method 'Point::Point(const Point&)' first required here
/usr/include/QtCore/qobject.h: In member function 'Geometry& Geometry::operator=(const Geometry&)':
src/geometry.h:31: instantiated from 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = Point]'
/usr/include/QtCore/qlist.h:417: instantiated from 'void QList<T>::append(const T&) [with T = Point]'
src/linestring.cpp:68: instantiated from here
/usr/include/QtCore/qobject.h:287: error: 'QObject& QObject::operator=(const QObject&)' is private
src/geometry.h:31: error: within this context
src/point.h: In member function 'Point& Point::operator=(const Point&)':
src/point.h:31: note: synthesized method 'Geometry& Geometry::operator=(const Geometry&)' first required here
/usr/include/QtCore/qlist.h: In member function 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = Point]':
/usr/include/QtCore/qlist.h:332: note: synthesized method 'Point& Point::operator=(const Point&)' first required here
gmake: *** [linestring.o] Error 1
*** Exited with status: 2 ***
To copy to clipboard, switch view to plain text mode
I've read, that the copy constructor of QObject is private though it's not possible to make copies from derived objects.
But the whole Qt object hierarchy does it the same QObject -> QFrame -> QAbstractScrollArea -> QTextEdit
Why does this work? Where is the problem with my code?
Bookmarks