Results 1 to 5 of 5

Thread: <SOLVED> How to use QGuiApplication::applicationStateChanged in normal application

  1. #1
    Join Date
    Oct 2011
    Posts
    51
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default <SOLVED> How to use QGuiApplication::applicationStateChanged in normal application

    I'm creating an application for android device, and I want to use android activities "signals" (onPause etc.). I read that I can use QGuiApplication::applicationStateChanged() signal to check my application state, but I don't know how (and if it's possible) to use this signal in 'normal' QApplication app, not QML. Or maybe if there is some other way of getting those signals in my application?
    Last edited by cszawisza; 27th May 2014 at 22:24.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QGuiApplication::applicationStateChanged in normal application


  3. The following user says thank you to anda_skoa for this useful post:

    cszawisza (27th May 2014)

  4. #3
    Join Date
    Oct 2011
    Posts
    51
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QGuiApplication::applicationStateChanged in normal application

    When using AGuiApplication instead of QApplication, you just need to connect signal to slot, that's simple But...
    Normally simple, created by QtCreator applications starts with main function like
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. MainWindow w;
    5. w.show();
    6.  
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 
    I can not simply change QApplication to QGuiApplication because
    Qt Code:
    1. QWidget: Cannot create a QWidget without QApplication
    To copy to clipboard, switch view to plain text mode 
    So I need to have a QApplication object to run my application, and while I'm using it, I can't create a QGuiApplication object... So it can not by solved using simple signal to slot connection.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to use QGuiApplication::applicationStateChanged in normal application

    QApplication is-a QGuiApplication and has all those signals and more.

  6. The following user says thank you to ChrisW67 for this useful post:

    cszawisza (27th May 2014)

  7. #5
    Join Date
    Oct 2011
    Posts
    51
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QGuiApplication::applicationStateChanged in normal application

    QApplication
    Signals:
    8 signals inherited from QGuiApplication
    I don't know how I missed that... Thanks

Similar Threads

  1. How to block the normal buttons of a QWidget
    By Momergil in forum Qt Programming
    Replies: 3
    Last Post: 4th January 2012, 13:32
  2. Replies: 3
    Last Post: 4th September 2010, 23:48
  3. Replies: 1
    Last Post: 29th May 2010, 00:01
  4. Start application minimized or normal
    By matze in forum Qt Programming
    Replies: 3
    Last Post: 12th January 2010, 15:57
  5. Difference between normal socket and QTcpSocket
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 16th June 2007, 05:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.