7 #include <QGraphicsPixmapItem> 8 #include <QGraphicsScene> 10 #include "ViewPreview.h" 15 QGraphicsView (scene, parent),
16 m_viewAspectRatio (viewAspectRatio)
18 setMouseTracking(
true);
23 QPointF pos = mapToScene (event->pos ());
31 QGraphicsView::mouseMoveEvent (event);
36 if (m_viewAspectRatio == VIEW_ASPECT_RATIO_ONE_TO_ONE) {
38 fitInView (scene()->sceneRect(),
46 bool foundImage =
false;
47 for (
int i = 0; i < scene()->items().count (); i++) {
48 const QGraphicsItem *item = scene()->items().at (i);
49 const QGraphicsPixmapItem *itemPixmap =
dynamic_cast<const QGraphicsPixmapItem*
> (item);
50 if (itemPixmap != 0) {
52 fitInView (itemPixmap->boundingRect());
58 fitInView (scene()->itemsBoundingRect ());
61 QGraphicsView::resizeEvent (event);
void signalMouseMove(QPointF pos)
Forward the mouse move events.
ViewAspectRatio
Prevent aspect ratio distortion in certain previews by providing fixed 1:1 aspect ratio option...
virtual void mouseMoveEvent(QMouseEvent *event)
Intercept cursor move events and forward them.
virtual void resizeEvent(QResizeEvent *event)
Intercept resize events so we can rescale to the graphics items just fit into the resized window...
virtual void wheelEvent(QWheelEvent *event)
Intercept wheel event and discard it so accidentally moving the wheel does not move drawn items out o...
ViewPreview(QGraphicsScene *scene, ViewAspectRatio viewAspectRatio, QWidget *parent=0)
Single constructor.