I'm trying to use a QList, a custom class (class Edge:public QGraphicsLineItem), but when I use .append or anything else I got compilation errors
call to implicitly-deleted copy constructor of 'Edge'
current->v = new T(*reinterpret_cast<T*>(src->v));
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Graphboard.cpp
void GraphBoard::createEdge()
{
Edge newEdge(item1,item2);
edges.append(newEdge);
}
In my GraphBoard.h
QList<Edge> edges;
Maybe I should use *edges here but I get the same error...
I'm doing something wrong with custom class and QList. I already saw this topic Call to implicitly deleted copy constructor but I don't really know what I can take on this.
Here is Edge Defintion, I remove unused stuff:
#include <QObject>
#include <QWidget>
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
class Edge:public QGraphicsLineItem
{
QGraphicsEllipseItem * state1;
QGraphicsEllipseItem * state2;
public:
enum { Type = UserType + 2 };
int type() const override;
Edge(QGraphicsEllipseItem * s1, QGraphicsEllipseItem* s2);
QList<QPointF> centerPoints();
};
You can't get copy of any object in c++ which class don't have a copy constructor. To use pointers is a solution, but writing copy constructor is easy and safe. For more information about copy constructors watch here.