Forums

OverviewFelgo 2 Support (Qt 5) › How to detect my app goes to background?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22055

    jrrobles79

    Hi, maybe this is a very simple question, but I haven’t found out how to fix it, my app is freezing after an user click on an interstitial (chartboost), and the appstore is open, after that  I go back to my app and is not responding, how do I detect when I leave my app and when I come back, to try and save a state, if an interstitial is clicked. or if there is a way to disable the click of the interstitial? I’m interested on showing ad’s but that the ad’s don’t interrupt the performance of my app.

    #22060

    Gerald

    In your Main.qml file use this code to detect when your app loses or gets focus:

     

    Connections {
           target: Qt.application
           // Qt.application.state:     0 - mimimized
           //                           2 - lost focus
           //                           4 - got focus
           onStateChanged: {
    
                if (Qt.application.state === 0) {
                    
                    console.log("App StateChanged to 'App minimized' (" + Qt.application.state + ")")
                }
                else if (Qt.application.state === 2) {
                    
                    console.log("App StateChanged to 'App lost focus' (" + Qt.application.state + ")")
                }
                else if (Qt.application.state === 4) {
                    
    	      console.log("App StateChanged to 'App got focus' (" + Qt.application.state + ")")
    	  }
          }
    }
    

     

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support