Hi,
I have created a subclass from QGraphicsItem
};
class Node : public QGraphicsItem{
};
To copy to clipboard, switch view to plain text mode
and added few nodes using following code to a QGraphicsscene
for(int j=0;j<no_of_nodes;j++){
Node *node = new Node();
node
->apply_color
(QColor(Qt
::green));
node->setPos(0,0);
node->apply_text(node_name[j]);
scene->addItem(node);
}
for(int j=0;j<no_of_nodes;j++){
Node *node = new Node();
node->apply_color(QColor(Qt::green));
node->setPos(0,0);
node->apply_text(node_name[j]);
scene->addItem(node);
}
To copy to clipboard, switch view to plain text mode
Now i want to access these nodes later for changing color (apply_color() function defined in Node). I looked at a function called
QList<QGraphicsItem *> scene->items();
QList<QGraphicsItem *> scene->items();
To copy to clipboard, switch view to plain text mode
so i tried to get the list of graphicalitems using
QList<Node *> listofitems = scene->items();
QList<Node *> listofitems = scene->items();
To copy to clipboard, switch view to plain text mode
but im getting the following error
conversion from ‘QList<QGraphicsItem*>’ to non-scalar type ‘QList<Node*>’ requested
And how does the QList<QGraphicsItem *> scene->items(); return items ??? in the same order as they are added???
I have also uploaded the code
Thanx
Bookmarks