14 setMouseTracking(
true);
15 setCursor(Qt::PointingHandCursor);
16 this->installEventFilter(
this);
17 std::cout <<
"mousetracking activated!\n";
21 _backgroundImage = image.copy();
22 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
23 setFixedSize(image.size());
24 QImage newImage(image.size(), QImage::Format_ARGB32);
25 newImage.fill(Qt::white);
26 QPainter painter(&newImage);
27 painter.drawImage(QPoint(0, 0), _backgroundImage);
28 _backgroundImage = newImage;
34 return _backgroundImage.size();
39 if (event->type() == QEvent::MouseButtonPress)
50 if (event->button() == Qt::LeftButton)
53 _lastPoint =
event->pos();
55 _center.setX(_backgroundImage.size().rwidth() / 2);
56 _center.setY(_backgroundImage.size().rheight() / 2);
57 offset.setX(_lastPoint.x() - _center.x());
58 offset.setY(_lastPoint.y() - _center.y());
65 std::cout <<
"Mouse is moving!\n";
70 QPainter painter(
this);
71 QRect dirtyRect =
event->rect();
72 painter.drawImage(dirtyRect, _backgroundImage, dirtyRect);