how to draw QGraphicsPolygonItem
-
Hi
Its very good you use qDebug() but would be even nicer if you added some text so
its easier to follow what is what.qDebug() <<"graphicsView::addPoint - qv_points: " << qv_points;
Anyway, it looks very odd as list suddenly is empty.
It looks all is inside same class so unless you call clear on it
i see no way it suddenly goes empty.However, looking at the posted code, there is also nowhere - where you add to the qv_points list.
-
Hi
Its very good you use qDebug() but would be even nicer if you added some text so
its easier to follow what is what.qDebug() <<"graphicsView::addPoint - qv_points: " << qv_points;
Anyway, it looks very odd as list suddenly is empty.
It looks all is inside same class so unless you call clear on it
i see no way it suddenly goes empty.However, looking at the posted code, there is also nowhere - where you add to the qv_points list.
@mrjj is there anyway to debug like in visual studio where you can step over etc.?
I would just like to see what qv_points does with each action.
-
Hi
Its very good you use qDebug() but would be even nicer if you added some text so
its easier to follow what is what.qDebug() <<"graphicsView::addPoint - qv_points: " << qv_points;
Anyway, it looks very odd as list suddenly is empty.
It looks all is inside same class so unless you call clear on it
i see no way it suddenly goes empty.However, looking at the posted code, there is also nowhere - where you add to the qv_points list.
@mrjj said in how to draw QGraphicsPolygonItem:
However, looking at the posted code, there is also nowhere - where you add to the qv_points list.
the first line of addPoint() is where the point is added to the qv_points.
void graphicsView::addPoint(QPointF pos) { qv_points << pos; -
@mrjj said in how to draw QGraphicsPolygonItem:
However, looking at the posted code, there is also nowhere - where you add to the qv_points list.
the first line of addPoint() is where the point is added to the qv_points.
void graphicsView::addPoint(QPointF pos) { qv_points << pos;@hobbyProgrammer
Hi
Ah i miss that as i was looking for append or similar :)Yes, just start the app in debug mode (f5)
Then place a break point.
Then press F10 to step or F11 -
@hobbyProgrammer
Hi
Ah i miss that as i was looking for append or similar :)Yes, just start the app in debug mode (f5)
Then place a break point.
Then press F10 to step or F11@mrjj oh thanks!
I got the error: Unable to create a debugging engine.
but I didn't have any debuggers for MSVC. I did have two for minGW so I added those kits to my project and now I can view them hopefully. -
@hobbyProgrammer
Hi
Ah i miss that as i was looking for append or similar :)Yes, just start the app in debug mode (f5)
Then place a break point.
Then press F10 to step or F11This post is deleted! -
@mrjj
I managed to see that it shows up empty in the addPolygon function, but when I add a new point it still shows the old points in the debugger.This is what I get in the debugger:
qv_points in addPoint: QVector(QPointF(27,40)) qv_points in addPoint: QVector(QPointF(27,40), QPointF(50,229)) qv_points in addPoint: QVector(QPointF(27,40), QPointF(50,229), QPointF(151,236)) qv_points in addPoint: QVector(QPointF(27,40), QPointF(50,229), QPointF(151,236), QPointF(152,147)) addPoly() qv_points: QVector() addPoly() qv_points: QVector() addPoly() qv_points: QVector() qv_points in addPoint: QVector(QPointF(27,40), QPointF(50,229), QPointF(151,236), QPointF(152,147), QPointF(245,129)) -
hi
The debugger for visual studio is a separate download called
Debugging tools from MS.When you press Ctrl+N , you are not creating a new instance of the
graphicsView or something like that ? -
hi
The debugger for visual studio is a separate download called
Debugging tools from MS.When you press Ctrl+N , you are not creating a new instance of the
graphicsView or something like that ?@mrjj yes I did! Thank you so much.
I had this in the create actions
GraphicsView gv = new GraphicsView; addPolyAct = new QAction(tr("&Add Poly..."), this); addPolyAct->setShortcut(QKeySequence::New); connect(addPolyAct, SIGNAL(triggered()), gv , SLOT(addPoly()));since I promoted the widget inside the designer I changed it to:
addPolyAct = new QAction(tr("&Add Poly..."), this); addPolyAct->setShortcut(QKeySequence::New); connect(addPolyAct, SIGNAL(triggered()), ui->graphicsView, SLOT(addPoly()));Now everything works perfectly!
Thank you so much. -
@mrjj yes I did! Thank you so much.
I had this in the create actions
GraphicsView gv = new GraphicsView; addPolyAct = new QAction(tr("&Add Poly..."), this); addPolyAct->setShortcut(QKeySequence::New); connect(addPolyAct, SIGNAL(triggered()), gv , SLOT(addPoly()));since I promoted the widget inside the designer I changed it to:
addPolyAct = new QAction(tr("&Add Poly..."), this); addPolyAct->setShortcut(QKeySequence::New); connect(addPolyAct, SIGNAL(triggered()), ui->graphicsView, SLOT(addPoly()));Now everything works perfectly!
Thank you so much.Ok. Good. :)
It was my only guess
how on earth the points list could become
empty.
Sometimes Im a lucky guesser :)