//Dialog.h
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include<QMouseEvent>
class Dialog : public QDialog
{
Q_OBJECT
public:
void mousePressEvent(QMouseEvent*);
void Dialog::paintEvent(QPaintEvent *);
Dialog(QWidget *parent = 0);
~Dialog();
};
#endif // DIALOG_H
//Dialog.cpp
#include "dialog.h"
#include<QDebug>
#include<QPainter>
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
}
Dialog::~Dialog()
{
}
void Dialog::mousePressEvent(QMouseEvent *event)
{
qDebug()<<event->pos();
}
void Dialog::paintEvent(QPaintEvent *)
{
// QPainter painter(this);
// QPixmap pix(164*4,85*4);
// pix.fill(Qt::green);
// painter.drawPixmap(100,0,pix);
// QPainter painter2(this);
// QPixmap pix2(164,85);
// pix2.fill(Qt::red);
// painter2.drawPixmap(100,200,pix2);