×
Namespaces

Variants
Actions

Talk:Listening for Symbian key events in Qt

From Nokia Developer Wiki
Jump to: navigation, search

There's a small error in one of the example code snippets. The flagging is off in this:

void QMyWidget::keyPressEvent(QKeyEvent* event)

   {
   #ifdef Q_OS_SYMBIAN
   switch (event->nativeVirtualKey())
     {
     case EKeyUpArrow:
     {
     // Symbian EKeyUpArrow pressed 
     break;
     }
   };
   }
   #endif

The closing #endif should be BEFORE the last bracket, like this:

void QMyWidget::keyPressEvent(QKeyEvent* event)

   {
   #ifdef Q_OS_SYMBIAN
   switch (event->nativeVirtualKey())
     {
     case EKeyUpArrow:
     {
     // Symbian EKeyUpArrow pressed 
     break;
     }
   };
   #endif
   }

not working in S60 3rd FP1 -Emulator with Qt 4.6.2?

I implemented a small Qt-Application, derived from a QDialog.

My QDialog containes several QButtons, QLabels, QLineEdits and so on (via .ui-file).

In the myQDialog.h I declare the 'void keyPressEvent(QKeyEvent *aEvent);' which I also implement in myQDialog.cpp.

But when executing the program in the debugger it never enters that method, no matter what key I press on the emulator.

Does this have something to do with QWidget::setFocusPolicy() ? Is the keyPressEvent possibly 'consumed' by other widgets inside myQDialog?

 
×