PDA

View Full Version : Drawing on QGraphicsItem.



ommharidaas
8th September 2011, 13:41
Is it possible to draw a grid on a QGraphicsItem?
And
Is it possible to resize that grid with the help of any events?

Could use all the help i get.
thnx.

wysota
8th September 2011, 14:44
Is it possible to draw a grid on a QGraphicsItem?
Yes.


Is it possible to resize that grid with the help of any events?
Yes.

ommharidaas
8th September 2011, 16:01
Could u show some code snippets or point me in the direction as to how to go about doin so?
I want to draw a resizable grid on QGraphicsItem and be able to place small icons in grid cells.
Thanks for ur response wysota!
:)

helloworld
8th September 2011, 16:49
Is there a specific reason why you don't want to use, for example, QGraphicsScene::drawBackground() to draw the grid and then place the items as individual QGraphicsItems on the scene?

ommharidaas
8th September 2011, 17:05
Is there a specific reason why you don't want to use, for example, QGraphicsScene::drawBackground() to draw the grid and then place the items as individual QGraphicsItems on the scene?


No, coz thats not what I want to achieve.
I have set a QGraphicsScene as a bgrnd, and for some specific reasons, I want to add an QGraphicsItem on that using
scene->addItem(item).
And I want to b able to draw d grid on that item and not on the scene. I hope I hv put down my doubt clearly.
Can use all the help.
Thnx.

helloworld
8th September 2011, 19:33
If this suits your needs, the easiest way is probaby to create a subclass of QGraphicsItem, reimplement paint() and simply draw the grid from there.

wysota
8th September 2011, 20:03
Make your grid a child item of the item you want it to be drawn on. Make the icons child items of the grid item.

ommharidaas
9th September 2011, 13:05
Make your grid a child item of the item you want it to be drawn on. Make the icons child items of the grid item.


I have managed to draw a grid on QGraphicsSvgItem.
Now what i want to do is grab a lower right corner of that grid with mouse click and resize it.
if you could tell me how should i go about it !
Should i try to handle a resizeEvent or make the grid shrik and expand on mouseClickDrag or anything like that??
Please shed some light on this aspect as well.
Thanks.

wysota
9th September 2011, 13:20
If you want me to guide you step by step to implement your program then that's not going to happen. Learn a tool first before you start using it.

ommharidaas
21st September 2011, 13:40
If you want me to guide you step by step to implement your program then that's not going to happen. Learn a tool first before you start using it.

NO...Just a hint would have been nice! i dint ask you to write a god damm code for me!
Issue was solved by the way.
thank you all for all the help!