What steps will reproduce the problem? 1. reimplement QWidget::keyPressEvent 2. try to catch KEYCODE_BACK pressing
What is the expected output? What do you see instead? KEYCODE_BACK should be caught. The event goes to android framework.
What version of the product are you using? On what operating system? latest sources from git. OS: Snow Leopard
Please provide any additional information below.
I noticed that there is a line in QTDIR/src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java
...
public boolean onKeyDown(int keyCode, KeyEvent event)
....
if (keyCode != KeyEvent.KEYCODE_BACK)
QtApplication.keyDown(keyCode, c, event.getMetaState());
return true;
...
Looks like this code breaks propagation KEYCODE_BACK to Qt. I would test this by myself, but I can't find a place on a device where QtActivity.java is located.
Thanks
Comment #1
Posted on May 27, 2011 by Swift Horse(No comment was entered for this change.)
Comment #2
Posted on Nov 18, 2011 by Massive WombatI found out that the android back button triggers a close event in Qt. So all you have to do to catch this to implement your own handler.
I did this by implementing a class 'MyGraphicsView' derived from QGraphicsView where I re-implement the following method:
void MyGraphicsView::closeEvent(QCloseEvent *pEvent)
Comment #3
Posted on Nov 18, 2011 by Quick Dogthat's what I did after posting the issue.
Comment #4
Posted on Jan 6, 2012 by Swift Wombati also tried to re-implement 'closeEvent' but my app still exits when i hit the back key. this is my code: void MobileApp::closeEvent(QCloseEvent *event){ //do somthing }
(mobile app exetends QDialog) any idea?
Comment #5
Posted on Feb 9, 2012 by Happy HorseI try the same at doesnt work
Comment #6
Posted on Apr 6, 2012 by Swift HorseFixed in http://quickgit.kde.org/?p=android-qt.git&a=commit&h=6dc070ff2715fd75e0e8576aa6f4c524b824ad42 will be shipped in alpha4 release.
Status: Fixed
Labels:
Type-Defect
Priority-Medium