use peg.setPos(x, y) to set that item in a particular location on scene ...
increase the ellipse size a little ... its very tiny on a big scene ...hahaha ..
use peg.setPos(x, y) to set that item in a particular location on scene ...
increase the ellipse size a little ... its very tiny on a big scene ...hahaha ..
"Behind every great fortune lies a crime" - Balzac
your code is completed ... see your item in the attachment ...
actually u need to inherit QObject with your custom QGraphicsItem ...
that is the problem ... now it solved ... also use setPos() in QGraphicsScene()..
Qt Code:
{ Q_OBJECT //if u need any connect in futureTo copy to clipboard, switch view to plain text mode
have a good day
"Behind every great fortune lies a crime" - Balzac
Hi:
So thanks for the help. But even though I did what you told me it still did not appear. But I figured out the problem and it did not have anything to do with QGraphicsView Framework and everything to do with C++.
I chaged this code
Qt Code:
Peg peg(Qt::red); scene->addItem(&peg);To copy to clipboard, switch view to plain text mode
with this code
Qt Code:
Peg *peg = new Peg(Qt::red); scene->addItem(peg);To copy to clipboard, switch view to plain text mode
It seems that by creating the local variable peg instead of a pointer it gets destroy at the end of the constructor therefore, it never shows up in the screen.
Thanks for all the help, I'll probably be posting more of my problems.
Bookmarks