43 lines
949 B
C++
43 lines
949 B
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QObject>
|
|
#include <QDebug>
|
|
#include <QEvent>
|
|
#include <QWheelEvent>
|
|
|
|
#include <QGraphicsView>
|
|
#include <QGraphicsScene>
|
|
//#include <QGraphicsItem>
|
|
//#include <QPainter>
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
class CvGraphicsViewWidget :public QGraphicsView
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CvGraphicsViewWidget(QWidget* parent = Q_NULLPTR);
|
|
virtual ~CvGraphicsViewWidget() {}
|
|
|
|
public:
|
|
void showImage(cv::Mat const& _himg);
|
|
|
|
static void CvImage2QPixmap(cv::Mat const& fromCv, QPixmap& toPix);
|
|
static bool QImage2CvImage(QImage& fromQ, cv::Mat& toCv);
|
|
//static void QPixmapToCvRegion(QPixmap const& _pix, cv::Rect2d& tarImg);
|
|
|
|
protected:
|
|
//void paintEvent(QPaintEvent* event) override;
|
|
//void wheelEvent(QWheelEvent* ev);
|
|
|
|
private:
|
|
QGraphicsScene* mGraphicsScene;
|
|
//QGraphicsRectItem* item;
|
|
|
|
//QColor penColor = QColor(0, 180, 255);//画笔颜色
|
|
//int penWidth = 2;//画笔宽度
|
|
qreal mScaledFactor; //窗口缩放倍数
|
|
|
|
}; |