Thank you for your help once more, its working now, it was an invalid pointer like you said. Concerning the clone() , its the only way I knew how to retrieve the object instances, I am still newbie in this. I am going to try and implement as you advise.Thank you.
I got another question please if I am still allowed. The nodes(QGraphicsRectItems) in the scene keeps crossing paths. I know I am supposed to set the setPos() for each of the nodes on the scene but I do not how to store the items so that I can set individual setPos(). I read my data from the object instance like this:
void GatewayWidget::addRect(DM::Object *_pTitle)
{
C2DM::RouteState *pRoute = (C2DM::RouteState*)_pTitle;
text
= scene
->addText
(QString::fromStdString(pRoute
->m_strSource
));
// pRoute->Source may contain 4, 8 or any number of nodes that are retried from the data text->setPos(600, (qrand() % 400)); //try to setpos() but its ugly
void GatewayWidget::addRect(DM::Object *_pTitle)
{
C2DM::RouteState *pRoute = (C2DM::RouteState*)_pTitle;
QGraphicsRectItem *rectangle;
QGraphicsTextItem *text;
text = scene->addText(QString::fromStdString(pRoute->m_strSource));// pRoute->Source may contain 4, 8 or any number of nodes that are retried from the data
text->setPos(600, (qrand() % 400)); //try to setpos() but its ugly
rectangle = new QGraphicsRectItem(QRectF(0, 0, 60, 60), text); //then put it in QGraphicsRectItems
To copy to clipboard, switch view to plain text mode
I tried to set randomly position them, which is not ideal. Now this makes the QGraphicsLineItems *line that I use to connect source and destination to cross paths(please see attachment). So I am asking for your guidance, on how I can store the nodes(pRoute->Source) ,which will enable me to retrieve and setPos() for each QGraphicRectItem?
Bookmarks