PDA

View Full Version : Custom objects in a QGraphicScene



draand
24th July 2007, 10:55
Hi there,
I am trying to create some custom objects and use them in a GraphicScene
The objects should have some editable text boxes which should allow setting some of the parameters of the object. The only thing I saw appropriate for this would be QGraphicsTextItem.

My question is:
- could I have more complex stuff in a GraphicsItem like comboBoxes, LineEdits or other advanced editable objects? How could I include this stuff in QGraphicsItem?


Cheers

marcel
24th July 2007, 10:59
I am trying to create some custom objects and use them in a GraphicScene
The objects should have some editable text boxes which should allow setting some of the parameters of the object. The only thing I saw appropriate for this would be QGraphicsTextItem.

You should subclass QGraphicsItem and do everything in there. Maybe this should be an item group, containing a text item and possibly something else, depending on what you need.



My question is:
- could I have more complex stuff in a GraphicsItem like comboBoxes, LineEdits or other advanced editable objects? How could I include this stuff in QGraphicsItem?

There has been an attempt:
http://labs.trolltech.com/blogs/2007/04/02/graphics-view-with-layouts-and-widgets/

But my guess is you should make your own items that behave that way. For example, like a combo box.
This way you could really customize their look&feel very easy, since it's all a matter of drawing something in the right place.

Regards

draand
24th July 2007, 11:31
Yes, sub classing QGraphicsItem is what I'm doing anyway ...but it is just not enough :(
I think it all comes down to displaying QWidgets on the scene. Following your link I stumbled upon http://labs.trolltech.com/page/Projects/Graphics_View/Graphics_Items which mostly summarizes my problem.
If you know more about this issue or have other example of such implementations I would really appreciate the help :)

Thanks for the link! :)