程序
.h
#ifndef EVENTFILTER_H
#define EVENTFILTER_H
#include <QDialog>
#include <QLabel>
class EventFilter : public QDialog
{
Q_OBJECT
public:
EventFilter(QWidget *parent = 0);
~EventFilter();
public slots:
bool eventFilter(QObject *, QEvent *);
private:
QLabel *label1;
QLabel *label2;
QLabel *label3;
QLabel *stateLabel;
QImage Image1;
QImage Image2;
QImage Image3;
};
#endif
.cpp
#include "eventfilter.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QEvent>
#include <QMouseEvent>
#include <QMatrix>
EventFilter::EventFilter(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(tr("事件过滤"));
label1 = new QLabel;
Image1.load("D:/Qtc/EventFilter/image/1.png");
label1->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
label1->setPixmap(QPixmap::fromImage(Image1));
label2 = new QLabel;
Image2.load("D:/Qtc/EventFilter/image/2.png");
label2->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
label2->setPixmap(QPixmap::