I find a doc in wiki about how to get.but It doesn't work!!
the QApplication::symbianEventFilter can't receive the EEventFocusGained and EEventFocusLost signal.
my phone is N8
I use QtSDK1.1.3
http://www.developer.nokia.com/Commu...Qt_for_Symbian
I find a doc in wiki about how to get.but It doesn't work!!
the QApplication::symbianEventFilter can't receive the EEventFocusGained and EEventFocusLost signal.
my phone is N8
I use QtSDK1.1.3
http://www.developer.nokia.com/Commu...Qt_for_Symbian
If you want a signal during each time app be foreground and background.
QApplication::focusChanged
regards,
No,that signal is between two QWidget.
I need the application change to foregound and background.
This article has code ,http://doc.qt.nokia.com/4.7-snapshot...tml#properties
Whenever the application is active it will show application is active or not ? Just check.
Otherwise you have to achieve that using Symbian specific code. from the article you mention in #1
regards,
How your code looks like?
that's QML,but I use QT.
this is my code:
bool MyApplication::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;
}
return false;
}
Instead of filtering symbian events, you might want to filter Qt events: QEvent::ApplicationActivate and QEvent::ApplicationDeactivate.
And you created instance of MyApplication in your main.cpp file?
Well, it should still work for S^3. Try this:
Actually, QApplication::focusChanged() signal can be used as well. When you're application comes to foreground, 'old' widget is NULL and 'now' is nonzero, and vice versa when it goes to background.Code:#include <QtGui> #include <QDebug> #ifdef Q_OS_SYMBIAN #include <QSymbianEvent> #include <w32std.h> #endif class MyApplication : public QApplication { Q_OBJECT 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; } return false; } #endif // Q_OS_SYMBIAN }; #include "main.moc" int main(int argc, char *argv[]) { MyApplication a(argc, argv); QMainWindow w; w.showMaximized(); return a.exec(); };
It's worth noting that both of these methods give you 'focus lost-focus gained' events also when there's a global dialog/note (e.g. alarm, 'charging...', etc.) briefly displayed on screen.