最主要的是重写paintEvent()函数,下面直接看代码
mylabel.h
# pragma execution_character_set("utf-8")
#ifndef MYLABEL_H
#define MYLABEL_H
#include <list>
#include <map>
#include<QLabel>
#include<QPoint>
#include<QMouseEvent>
#include<QPainter>
#include<QWidget>
#include<QDebug>
#include<iostream>
#include<QString>
#include<QImage>
using namespace std;
#define WIDTH 640
#define HEIGHT 360
class MyLabel : public QLabel
{
Q_OBJECT
public:
MyLabel(QWidget *parent = 0);
protected:
void paintEvent(QPaintEvent *event);
private slots :
void slotGetOneFrame(QImage img);
private:
QImage wb_Image;
};
#endif // MYLABEL_H# p