Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User wangruiwz's Avatar
    Join Date
    Jan 2011
    Posts
    56
    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

  2. #2
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,293
    If you want a signal during each time app be foreground and background.

    QApplication::focusChanged

    regards,

  3. #3
    Registered User wangruiwz's Avatar
    Join Date
    Jan 2011
    Posts
    56
    No,that signal is between two QWidget.
    I need the application change to foregound and background.

  4. #4
    Nokia Developer Champion rahulvala's Avatar
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,293
    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,

  5. #5
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    How your code looks like?

  6. #6
    Registered User wangruiwz's Avatar
    Join Date
    Jan 2011
    Posts
    56
    Quote Originally Posted by rahulvala View Post
    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,
    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;
    }

  7. #7
    Nokia Developer Expert Fuzzbender's Avatar
    Join Date
    Feb 2008
    Posts
    183
    Instead of filtering symbian events, you might want to filter Qt events: QEvent::ApplicationActivate and QEvent::ApplicationDeactivate.

  8. #8
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    And you created instance of MyApplication in your main.cpp file?

  9. #9
    Registered User wangruiwz's Avatar
    Join Date
    Jan 2011
    Posts
    56
    Quote Originally Posted by Fuzzbender View Post
    Instead of filtering symbian events, you might want to filter Qt events: QEvent::ApplicationActivate and QEvent::ApplicationDeactivate.
    It's not for symbian,it's for desktop.

    Quote Originally Posted by savaj View Post
    And you created instance of MyApplication in your main.cpp file?
    of course

  10. #10
    Regular Contributor treinio's Avatar
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329
    Well, it should still work for S^3. Try this:

    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();
    };
    Quote Originally Posted by wangruiwz View Post
    No,that signal is between two QWidget.
    I need the application change to foregound and background.
    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.

    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.

Similar Threads

  1. application background, foreground
    By chank_13 in forum Symbian C++
    Replies: 7
    Last Post: 2010-03-30, 11:38
  2. texteditor, background, foreground
    By noman_csedu in forum Symbian C++
    Replies: 4
    Last Post: 2007-08-22, 08:11
  3. background and foreground
    By TrungThanhMtad in forum Symbian C++
    Replies: 1
    Last Post: 2005-10-27, 13:48
  4. SIP Background - Foreground
    By iotuus in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2005-04-29, 09:06
  5. How to bring exe from background to foreground?
    By toughworker in forum Symbian C++
    Replies: 2
    Last Post: 2004-12-20, 00:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
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