Hi,
I have a custom QGraphicsscene like this
{
Q_OBJECT
public:
//...
DisjointSetsScene
(QObject *parent,
/* ... */);
//...
signals:
void signalNodeClicked(Node *node);
// ...
};
class DisjointSetsScene : public QGraphicsScene
{
Q_OBJECT
public:
//...
DisjointSetsScene(QObject *parent, /* ... */);
//...
signals:
void signalNodeClicked(Node *node);
// ...
};
To copy to clipboard, switch view to plain text mode
with some constructor
DisjointSetsScene
::DisjointSetsScene(QObject *parent,
/* ... */)
DisjointSetsScene::DisjointSetsScene(QObject *parent, /* ... */)
: QGraphicsScene(parent)
To copy to clipboard, switch view to plain text mode
I'm adding some custom graphics items and lines like this
NodeItem *nodeItem = new NodeItem();
nodeItem->setRect(startCoords.x(), startCoords.y(), 30, 30);
nodeItem->setBrush(nodeBrush);
nodeItem->setPen(nodePen);
//...
addLine(startCoords.x() + 15, startCoords.y() + 15, endCoords.x() + 15, endCoords.y() + 15, arrowPen);
//...
addItem(nodeItem);
NodeItem *nodeItem = new NodeItem();
nodeItem->setRect(startCoords.x(), startCoords.y(), 30, 30);
nodeItem->setBrush(nodeBrush);
nodeItem->setPen(nodePen);
//...
addLine(startCoords.x() + 15, startCoords.y() + 15, endCoords.x() + 15, endCoords.y() + 15, arrowPen);
//...
addItem(nodeItem);
To copy to clipboard, switch view to plain text mode
Now, at some point (when a node is clicked), i need to repaint the whole scene. So i want to clear it first, however, this thing
qDeleteAll(items());
qDeleteAll(items());
To copy to clipboard, switch view to plain text mode
gives me SIGSEGV. Any suggestions?
Bookmarks