×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    56

    how to get the singal of app be foreground and background?

    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
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: how to get the singal of app be foreground and background?

    If you want a signal during each time app be foreground and background.

    QApplication::focusChanged

    regards,

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    56

    Re: how to get the singal of app be foreground and background?

    No,that signal is between two QWidget.
    I need the application change to foregound and background.

  4. #4
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: how to get the singal of app be foreground 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,

  5. #5
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: how to get the singal of app be foreground and background?

    How your code looks like?

  6. #6
    Registered User
    Join Date
    Jan 2011
    Posts
    56

    Re: how to get the singal of app be foreground and background?

    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
    Join Date
    Feb 2008
    Posts
    183

    Re: how to get the singal of app be foreground and background?

    Instead of filtering symbian events, you might want to filter Qt events: QEvent::ApplicationActivate and QEvent::ApplicationDeactivate.

  8. #8
    Nokia Developer Champion
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: how to get the singal of app be foreground and background?

    And you created instance of MyApplication in your main.cpp file?

  9. #9
    Registered User
    Join Date
    Jan 2011
    Posts
    56

    Re: how to get the singal of app be foreground and background?

    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
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: how to get the singal of app be foreground and background?

    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
    Replies: 7
    Last Post: 2010-03-30, 11:38
  2. texteditor, background, foreground
    By noman_csedu in forum Symbian
    Replies: 4
    Last Post: 2007-08-22, 08:11
  3. background and foreground
    By TrungThanhMtad in forum Symbian
    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
    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
  •