Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Please help me handling UP and DOWN key in my class?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blue_sky
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      @ 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);
      

      }@


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rahul Das
        wrote on last edited by
        #3

        Take a look at" Event system":http://qt-project.org/doc/qt-4.8/eventsandfilters.html


        Declaration of (Platform) independence.

        1 Reply Last reply
        0
        • IamSumitI Offline
          IamSumitI Offline
          IamSumit
          wrote on last edited by
          #4

          Hello blue_sky..

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

          Be Cute

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved