[C++ GUI Programming with Qt4] chap7Presentation Transcript
C++ GUI Programming with Qt 4Chap7. Event Processing
Outline● 重新實現事件處理器● 安裝事件過濾器● 處理密集時的響應保持
7.1 QEvent● The QEvent class is the base class of all event classes● Qts main event loop (QCoreApplication::exec()) fetches native window system events from the event queue, translates them into QEvents, and sends the translated events to QObjects.
QWidget::event()● This is the main event handler; it handles event event● You can re-implement this function in a subclass, but we recommend using one of the specialized event handlers instead ( keyPressEvent(), mouseMoveEvent(), paintEvent(), etc... ).
Common Event Types (1)● 鍵盤事件 : keyPressEvent(), keyReleaseEvent()