PDA

View Full Version : Painting directly on the scene



maverick_pol
27th September 2007, 13:47
Hi guys,

I have a question. I the drawBackground(QPainter* painter) I am drawing my scene background, simple as that. The user, though, should be able to draw some other lines, polygons dynamically(with some give coordinates). I can do that adding items(as addline,addpolygon, etc, add items), but I would like to draw simply on the scene, using scene coordinates, using scene painter. Is it possible?

Maverick

wysota
27th September 2007, 13:52
You can't draw "on the scene". Scene is not drawable in any way. The only way to change the scene (which in turn will be visualized by the views) is to add items. So you can either add items to the scene or draw on the view's viewport (which is really not advised).

maverick_pol
27th September 2007, 14:23
Ok, that's understandable. So would it be a better idea to use a simple widget and paint on it? I am currently using QGraphicsView Framework, but I am wondering was it the best solution. I am drawing a map and have to draw some more items when user choses to do so(about thousands of items), have to zoom in/out, find object, collision, etc.

let's say, I have to add 100 000(or even a 1000 000) polygon items to the scene. How hard would it be to optimize it so I would see any painting lag/clutter while zoomin/out?

But is the GraphicsView Framework the best solution for this?..

Thank you for help.

wysota
27th September 2007, 14:55
Assuming you're implementing something similar to googlemaps and you want to place pins, labels or whatever, I'd go for graphics view and implement all those pins and other stuff as graphics items. Graphics View should work fine even for millions of items. Of course you can reduce the number of items by dynamically adding or removing them from the scene just like google does.