Namespaces
Variants
Actions
(Difference between revisions)

Detecting focus lost & gained events in Qt for Symbian

Jump to: navigation, search
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Qt]][[Category:Symbian]][[Category:UI]][[Category:Technical Solution]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition FP2]][[Category:S60 5th Edition]][[Category:Symbian C++]]
+
[[Category:Qt]][[Category:Symbian]][[Category:UI]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition FP2]][[Category:S60 5th Edition]][[Category:Symbian C++]]
__NOTOC__
+
{{ArticleMetaData <!-- v1.2 -->
__NOEDITSECTION__
+
{{KBTS}}
+
{{ArticleMetaData
+
|id=TSQ001585
+
|platform=S60 3rd Edition, FP1<br>S60 3rd Edition, FP2<br>S60 5th Edition<br>Qt 4.6.2
+
|devices=Symbian
+
|creationdate=26 April, 2010
+
|keywords=symbianEventFilter, focus
+
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Symbian
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|platform= S60 3rd Edition, FP1<br>S60 3rd Edition, FP2<br>S60 5th Edition<br>Qt 4.6.2
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Kbwiki]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= symbianEventFilter, focus
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 26 April, 2010
 +
|author= [[User:Kbwiki]]
 +
<!-- The following are not in current metadata -->
 +
|id= TSQ001585
 
}}
 
}}
  
Line 30: Line 37:
 
Define an application class that inherits {{Icode|QApplication}} and reimplement {{Icode|symbianEventFilter()}}:
 
Define an application class that inherits {{Icode|QApplication}} and reimplement {{Icode|symbianEventFilter()}}:
  
<code cpp>
+
<code cpp-qt>
 
   #include <QDebug>
 
   #include <QDebug>
 
    
 
    

Latest revision as of 04:16, 11 October 2012

Article Metadata

Tested with
Devices(s): Symbian

Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 5th Edition
Qt 4.6.2

Article
Keywords: symbianEventFilter, focus
Created: User:Kbwiki (26 Apr 2013)
Last edited: hamishwillee (11 Oct 2012)

Overview

This article explains how to detect focus change events in Qt applications on Symbian.

Description

Qt applications need to reimplement QApplication::symbianEventFilter() in order to get notification of foreground application changes, ie. focus lost & gained events. This is needed because focusInEvent(), focusOutEvent(), or hideEvent() from the QWidget class are not called on the Symbian platform when the foreground application changes.

Solution

Define an application class that inherits QApplication and reimplement symbianEventFilter():

  #include <QDebug>
 
#ifdef Q_OS_SYMBIAN
#include <QSymbianEvent>
#include <w32std.h>
#endif
 
 
class MyApplication : public QApplication
{
public:
MyApplication( int argc, char** argv ) : QApplication( argc, argv ) {}
 
#ifdef Q_OS_SYMBIAN
protected:
bool symbianEventFilter( const QSymbianEvent* symbianEvent ) {
const TWsEvent *event = symbianEvent->windowServerEvent();
 
if( !event ) {
return false;
}
 
switch( event->Type() ) {
case EEventFocusGained: {
qDebug() << "Focus gained";
break;
}
case EEventFocusLost: {
qDebug() << "Focus lost";
break;
}
default:
break;
}
 
// Always return false so we don't stop
// the event from being processed
return false;
}
#endif // Q_OS_SYMBIAN
};
This page was last modified on 11 October 2012, at 04:16.
251 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved