pixmapviewer.h 803 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef PIXMAPVIEWER_H
  2. #define PIXMAPVIEWER_H
  3. #include <QPainter>
  4. #include <QPixmap>
  5. #include <QWheelEvent>
  6. #include <QWidget>
  7. namespace Ui {
  8. class PixmapViewer;
  9. }
  10. class PixmapViewer : public QWidget {
  11. Q_OBJECT
  12. public:
  13. explicit PixmapViewer(QWidget* parent = nullptr);
  14. ~PixmapViewer();
  15. void paintEvent(QPaintEvent* event);
  16. void setImage(QPixmap& image);
  17. void setFactor(double factor);
  18. void wheelEvent(QWheelEvent* event);
  19. void mousePressEvent(QMouseEvent* event);
  20. void mouseReleaseEvent(QMouseEvent* event);
  21. void mouseMoveEvent(QMouseEvent* event);
  22. private:
  23. Ui::PixmapViewer* ui;
  24. QPixmap m_image;
  25. QPixmap m_tempPix;
  26. double m_factor;
  27. QPoint m_mousedownPoint;
  28. QPoint m_startPoint;
  29. bool m_mousedownFlag;
  30. };
  31. #endif // PIXMAPVIEWER_H