Advertisement
VlaoMao

myT.h

Nov 2nd, 2013
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #ifndef MYT_H
  2. #define MYT_H
  3. #include <QTextEdit>
  4. #include <QWheelEvent>
  5. #include <QApplication>
  6. #include <QDebug>
  7.  
  8. class myT : public QTextEdit
  9. {
  10.     Q_OBJECT
  11.  
  12. public slots:
  13.     void v()
  14.     {
  15.         qDebug() << Q_FUNC_INFO;
  16.         QWheelEvent e(QPoint(0,0),-120,0,0,Qt::Vertical);
  17.         this->setFocus();
  18.         qApp->sendEvent(this,&e);
  19.         //qApp->postEvent(this,e);
  20.         qApp->processEvents();
  21.     }
  22.  
  23.  
  24. protected:
  25.     bool event(QEvent *e)
  26.     {
  27.         QWheelEvent *ev = dynamic_cast<QWheelEvent*>(e);
  28.         if(ev)
  29.             qDebug() << ev->delta();
  30.         return QTextEdit::event(e);
  31.     }
  32.  
  33.     void wheelEvent(QWheelEvent *e)
  34.     {
  35.         qDebug() << "pos: " << e->pos();
  36.         qDebug() << "delta: " << e->delta();
  37.         qDebug() << "buttons: " << e->buttons();
  38.         qDebug() << "modifiers: " << e->modifiers();
  39.         qDebug() << "orient: " << e->orientation();
  40.  
  41.         QTextEdit::wheelEvent(e);
  42.     }
  43. };
  44.  
  45. #endif // MYT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement