PDA

View Full Version : need advice for GraphicsItem



alizadeh91
8th March 2012, 08:42
I want some advice :

I want to implement a Dial Component with Qt. I want to use a scene and add items(Dial components) to this scene. Here are my alternatives for choosing how implement items:
1) Use a QGraphicsItem and draw each layer(needle,overlay,background,shadow,...) of Dial by painter->DrawPixmap.
2) Use a QGraphicsObjec and use a scene onto it and draw each layer of Dial by QGraphicsPixmapItem.
3) Use a QWidget and the rest is same as 2.

Which of the above choice has best performance. Not that in first choice i dont know how to rotate a specific layer which i has drawn by painter->drawpixmap in paint method.

alizadeh91
8th March 2012, 18:05
Just to make it easy:
what is a good way to show a dial(has moving part(needle)) in Qt not qml. Is it QGraphicsItem or QGraphicsObject?

d_stranz
8th March 2012, 18:25
With the very small number of components you will have in this, it probably does not matter at all from a performance point of view which way you implement this. Probably QWidget is the simplest if you are implementing a component that you will put into other GUI layouts like a dialog.

If you want to do this as a learning experience, fine. If you want something you can use immediately (or maybe an example for how someone else has done it), you could take a look at AnalogWidgets (http://qt-apps.org/content/show.php/AnalogWidgets?content=87780) from the QtApps web site.


Is it QGraphicsItem or QGraphicsObject?

QGraphicsItem is more lightweight, and unless you need the needle to be able to emit signals or have slots, QGraphicsObject is overkill.