[Interest] Qt 5.6.1 widget app terminates if do not accept Android back key ?

Eddie Sutton eddie.of.the.spam at gmail.com
Fri Oct 7 21:09:28 CEST 2016


Thank you for your reply Jason.

> On Oct 7, 2016, at 1:01 PM, Jason H <jhihn at gmx.com> wrote:
> 
> It seems like the activity catches it and removes itself from the stack.
> Is it crashing? If so paste the exception.

I think maybe you are correct.

I see no exceptions in adb.  Instead it appeared the app was closed deliberately.  

Perhaps the problem is that I do not understand the Android back button.  Does an Android user expect the back button to close an app?


D/TSR     (25898): ../source/source/mainwindow.cpp:812 (virtual void tcmw::MainWindow::closeEvent(QCloseEvent*)): ************************* C L O S E ******************

I/ActivityManager(  563): Process com.ditchwitch.tsr (pid 25898) (adj 9) has died.
I/WindowState(  563): WIN DEATH: Window{42c61a48 u0 com.ditchwitch.tsr/com.ditchwitch.tsr.tsractivity.TsrActivity}
W/WindowManager(  563): Force-removing child win Window{42caa3f8 u0 SurfaceView} from container Window{42c61a48 u0 com.ditchwitch.tsr/com.ditchwitch.tsr.tsractivity.TsrActivity}



I expected Android button to retain my app state, suspend app to background, then restore suspended state when reactivated.


-Ed


> >Has anyone seen this?
>  
> I cannot find any useful clues in adb.
>  
> The app terminates unless I add a keyReleaseEvent to accept the Key_Back.
>  
>  
> #if defined(Q_OS_ANDROID)
> ///
> ///  Android back button kills TSR ?
> ///
> /// Adding a keyReleaseEvent that accepts the event prevents the crash.
> /// I do not understand reason why.
> ///
> /// Ignoring the Android back button will annoy users but is better than crashing.
> ///
> void MainWindow::keyReleaseEvent(QKeyEvent *event)
> {
>     if( Qt::Key_Back == event->key())
>     {
>         qDebug("Android Back button");
>         event->setAccepted(true);
>     }
> }
> #endif
>  
> Thanks in advance,
>  
> -Ed
>  
> _______________________________________________ Interest mailing list Interest at qt-project.org http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161007/bc08c8e9/attachment.html>


More information about the Interest mailing list