1. 程式人生 > >[Qt] postevent emit ----event與signal

[Qt] postevent emit ----event與signal

//QObject::event()在QWidget中被重新實現,對event的處理變得更完善。
bool QWidget::event( QEvent *e )

{
    if ( QObject::event( e ) )
    return TRUE;
 
    switch ( e->type() ) {
    case QEvent::MouseMove:
        mouseMoveEvent( (QMouseEvent*)e );
        break;
 
    case QEvent::MouseButtonPress:
        mousePressEvent( (QMouseEvent*)e );
        break;
 
    case QEvent::MouseButtonRelease:
        mouseReleaseEvent( (QMouseEvent*)e );
        break;
 
    case QEvent::MouseButtonDblClick:
        mouseDoubleClickEvent( (QMouseEvent*)e );
        break;
 
    case QEvent::Wheel:
        wheelEvent( (QWheelEvent*)e );
        if ( ! ((QWheelEvent*)e)->isAccepted() )
        return FALSE;
        break;
    case QEvent::KeyPress
: {
        QKeyEvent *k = (QKeyEvent *)e;
        bool res = FALSE;
        if ( k->key() == Key_Backtab ||
         (k->key() == Key_Tab &&
          (k->state() & ShiftButton)) ) {
        QFocusEvent::setReason( QFocusEvent::Tab );
        res = focusNextPrevChild( FALSE );
        QFocusEvent::resetReason();
 
        } else if ( k->key() == Key_Tab ) {
        QFocusEvent::setReason( QFocusEvent::Tab );
        res = focusNextPrevChild( TRUE );
        QFocusEvent::resetReason();
        }
        if ( res )
        break;
        QWidget *w = this;
        while ( w ) {
        w->keyPressEvent( k );

        if ( k->isAccepted() || w->isTopLevel() )