//.pro
TEMPLATE = app
CONFIG += c++11 console
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += \
main.cpp
#include <QApplication>
#include<QCoreApplication>
#include <QWidget>
#include <iostream>
using namespace std;
class A : public QWidget{
public:
bool event(QEvent *e);
void mousePressEvent(QMouseEvent *e);
};
bool A::event(QEvent *e){
static int i = 0;
cout << "E" << i++ << endl;
if(e->type() == QEvent::KeyPress)
std::cout << "Keydown" << std::endl;
return QWidget::event(e);
}
void A::mousePressEvent(QMouseEvent *e){
cout << "mouseDown" << endl;
return QWidget::mousePressEvent(e);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
A ma;
ma.resize(333, 222);
ma.show();
return a.exec();
}