PDA

View Full Version : QGraphicsView general questions



sincnarf
23rd August 2007, 04:05
Hello I am trying to reset a QGraphicsView's orientation to the same orientation it had before applying zoom and scale functions on the graphics view. My initial solution was to reload the pixmap item that the graphics view contained, but obviously that won't work. my question is how can i set the orientation of the graphics view to its default orientation (its orientation upon loading the whole application)

Off Topic Question : What does rubberbanding mean? I've read this in a lot of threads and still can't imagine what this does.

Off Topic Question: Can Anyone here direct/point me to a very good example of how to subclass QGraphicsView in order for me to place markers (dots) in my QGraphicsView? I was thinking of markers like in the Affine Transformations example in the demos of Qt. I can't understand the hoverpoint mechanism for the Affine Transformations example.

marcel
23rd August 2007, 06:25
You have to change the mapping back to identity:


QMatrix mapping = graphicsview->matrix();
mapping.reset(); //back to identity
graphicsview->setMatrix(mapping);


Regards

marcel
23rd August 2007, 09:43
Off Topic Question : What does rubberbanding mean? I've read this in a lot of threads and still can't imagine what this does.

A rubberband is a rectangle that appears when performing selections by dragging the mouse. Not only in graphics views but also in items views. It shows you the selection bounds.


Off Topic Question: Can Anyone here direct/point me to a very good example of how to subclass QGraphicsView in order for me to place markers (dots) in my QGraphicsView? I was thinking of markers like in the Affine Transformations example in the demos of Qt. I can't understand the hoverpoint mechanism for the Affine Transformations example.
No example, but subclassing the view and overriding drawForeground should solve the painting problem.
For interaction, you could override mouseMove/Press events for the view and check for the dots coordinates and act accordingly.

Regards

sincnarf
15th October 2007, 10:43
A rubberband is a rectangle that appears when performing selections by dragging the mouse. Not only in graphics views but also in items views. It shows you the selection bounds.

Okay, is there a way to get the item's contents based on the rubberband that was set? I want to implement sort of cropping the item. because I've read in the QGraphicsItem that rubberbanding the item only causes the selection of the whole item.



subclassing the view and overriding drawForeground should solve the painting problem. For interaction, you could override mouseMove/Press events for the view and check for the dots coordinates and act accordingly.

would using graphics ellipse items instead be better? See my problem is i've already created a sub class for a QGraphicsPixmapItem and it overrides the mousePressEvent(QGraphicsSceneMouseEvent *event) . . . but how can I add this item to my graphicsScene?

Gopala Krishna
15th October 2007, 15:19
Okay, is there a way to get the item's contents based on the rubberband that was set? I want to implement sort of cropping the item. because I've read in the QGraphicsItem that rubberbanding the item only causes the selection of the whole item.


Since rubberband's geometry is defined by the first mouse press position and the current mouse position you only need to reimplement QGraphicsView::mousePressEvent() and QGraphicsView::mouseMoveEvent().I guess you are better of to implement your own rubberbanding mechanism. Otherwise you might need to look at QGraphicsItem::ItemSelectionChange

By cropping do you mean image cropping or something similar ? If so an idea will be to draw a translucent pixmap in the foreground in the mouse events of graphics view instead of rubberband.



would using graphics ellipse items instead be better? See my problem is i've already created a sub class for a QGraphicsPixmapItem and it overrides the mousePressEvent(QGraphicsSceneMouseEvent *event) . . . but how can I add this item to my graphicsScene?

I didn't get you i think because its as simple as scene->addItem(pointer to your item);
I also suggest the ellipseItem way since that makes code simple (at the cost of bit of performance).
If you can explain what your app actually focuses on we might help you in a better way :)

sincnarf
16th October 2007, 00:22
By cropping do you mean image cropping or something similar ? If so an idea will be to draw a translucent pixmap in the foreground in the mouse events of graphics view instead of rubberband.
something similar. it's not actually cropping (sorry). From the QGraphicsItem, if I rubberband on the item, after releasing the mousebutton I need to :
1. let the rubberband stay there. the rubberband is only destroyed when I drag the mouse again.
2. on dragging and creation of rubber band, the contents of the rubberband must be initialized to an image. The QGraphicsItem need nod be changed. so ItemSelectionChange is not needed.



If you can explain what your app actually focuses on we might help you in a better way :)
well, my app is just a general framework that manages user (image processing functions). I need to implement capturing specific regions of interest in an image (into a new QImage). Also , the ellipses must be assigned to a Hashmap (maybe).
I am now also currently working on histograms for the image and other possible mechanisms that add to getting/setting image features... That's basically it.