#include <QWidget>class ttt : public QWidget{ Q_OBJECTpublic: explicit ttt(QWidget *parent = 0);protected: virtual void keyPressEvent(QKeyEvent* event) { int cp=1; } virtual void mousePressEvent( QMouseEvent* pe ) { int cp=1; }};
#include <QMainWindow>#include "ttt.h"class qqq : public QMainWindow{ Q_OBJECTpublic: explicit qqq(QWidget *parent = 0): QMainWindow(parent) { t = new ttt(); } ttt * t;};
#include "qqq.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); //ttt * frm = new ttt(); qqq * frm = new qqq(); frm->resize( 1200, 600 ); frm->show(); return a.exec();}
qqq::qqq(QWidget *parent) : QMainWindow(parent){ t = new ttt( this ); t->resize( 1200, 600 ); setCentralWidget( t );}
example::example(QWidget *parent) : QWidget(parent){ ui.setupUi(this); exmp* e = new exmp(this); QVBoxLayout*vbl = new QVBoxLayout(this); vbl->addWidget(e);}
virtual void keyPressEvent(QKeyEvent* event) { int cp=1; qDebug() <<"Keypressed "<<"cp ="<<cp; event->accept(); } virtual void mousePressEvent( QMouseEvent* pe ) { int cp=1; qDebug() <<"MousePressed"<<"cp ="<<cp; pe->accept(); }
#include "exmp.h"exmp::exmp(QWidget *parent) : QWidget(parent){ te = new QTextEdit(this); vbl = new QVBoxLayout(this); vbl->addWidget(te);}exmp::~exmp(){}