Please help me handling UP and DOWN key in my class?



  • void DgEzChannelView::keyPressEvent(QKeyEvent* e)
    {

    else if( e->key() == Qt::Key_Up )
    {
       
        }
    }
    else if( e->key() == Qt::Key_Down )
    {
     do stuff;
        }
    }
    

    }

    this is getting event for each every key pressed except up,down,right,left arrow key.May be QT core application is filtering the events before sending to my class.
    plz help how to get the events of these 4 keys from key board.



  • @ bool MyWidget::event(QEvent *event)
    {
    if (event->type() == QEvent::KeyPress) {
    QKeyEvent *ke = static_cast<QKeyEvent *>(event);
    if (ke->key() == Qt::Key_Tab) {
    // special tab handling here
    return true;
    }
    } else if (event->type() == MyCustomEventType) {
    MyCustomEvent *myEvent = static_cast<MyCustomEvent *>(event);
    // custom event handling here
    return true;
    }

     return QWidget::event(event);
    

    }@





  • Hello blue_sky..

    Your problem is solved ..
    just write "setFocus()" in MyWidget Constructor.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.