qt - c++ program crashes when adding new QGraphicsItem to scene -
my c++ program crashes when add new qgraphicslineitem qlist of qgraphicspixmapitem. below function.
void mainwindow::linkcomputernodes(qlist<node*> routers) { for(int i=0;i<routers.length();i++) { scene->additem(new link(routers.at(i),routers.at(i+1))); } }
your loop:
for(int i=0;i<routers.length();i++)
goes through every single router in list, add link each router router directly after it. means last router, trying add link 1 doesn't exist. try changing loop to:
for(int i=0;i<routers.length() - 1;i++)
so add links between existing routers.
Comments
Post a Comment