title: Qt Application Suspending
body: <p>How do I detect if my application has been suspended (when someone changes applications) and react by deactivating my timer and then re-activating it when my application becomes un-suspended (when someone re-opens my half running app). Beneath Is how far I have coded so far on this part my app but it gives an error: "'QApplication::QApplication(const QApplication&amp;)' is private" and it says within the context of myapp.cpp line 4. Please if anyone can tell me what I'm doing wrong it would be greatly appreciated.</p>
  
  <p>Here is my code for the main.cpp:</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "qmlapplicationviewer.h"
  #include &lt;QObject&gt;
  #include &lt;QGraphicsObject&gt;
  #include &lt;QTimer&gt;
  #include &lt;QVariant&gt;
  #include "timecontrol.h"
  #include "scorecontrol.h"
  #include "Retry.h"
  #include &lt;QEvent&gt;
  
  int main(int argc, char *argv[])
  {
  QApplication app(argc, argv);
  
  QmlApplicationViewer viewer;
  viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
  viewer.setMainQmlFile(QLatin1String("qml/Raker/main.qml"));
  viewer.showExpanded();
  
  QObject *rootObject = viewer.rootObject();
  
  QTimer *timmer = new QTimer;
  timmer-&gt;setInterval(1000);
  
  TimeControl *timcon = new TimeControl;
  
  scorecontrol *scorer = new scorecontrol;
  
  Retry *probeer = new Retry;
  
  QObject::connect(timmer, SIGNAL(timeout()), timcon, SLOT(updateTime()));
  QObject::connect(timcon, SIGNAL(setTime(QVariant)), rootObject, SLOT(setTime(QVariant)));
  QObject::connect(rootObject, SIGNAL(blockClicked(int, int)), scorer, SLOT(checkRight(int, int)));
  QObject::connect(scorer, SIGNAL(setScore(QVariant)), rootObject, SLOT(setScore(QVariant)));
  QObject::connect(scorer, SIGNAL(setState(QVariant)), rootObject, SLOT(setState(QVariant)));
  
  QObject::connect(rootObject, SIGNAL(start()), probeer, SLOT(Reetry()));
  QObject::connect(probeer, SIGNAL(start()), timmer, SLOT(start()));
  QObject::connect(probeer, SIGNAL(start(int)), scorer, SLOT(randomNum(int)));
  QObject::connect(probeer, SIGNAL(sReset()), timcon, SLOT(reset()));
  QObject::connect(probeer, SIGNAL(tReset()), scorer, SLOT(reset()));
  QObject::connect(timcon, SIGNAL(timeOut()), scorer, SLOT(reset()));
  
  QObject::connect(timcon, SIGNAL(setState(QVariant)), rootObject, SLOT(setState(QVariant)));
  QObject::connect(timcon, SIGNAL(changeFinal()), scorer, SLOT(changeFinal()));
  QObject::connect(scorer, SIGNAL(setFinal(QVariant)), rootObject, SLOT(setFinal(QVariant)));
  
  return app.exec();
  }
  </code></pre>
  
  <p>myApp.h:</p>
  
  <pre><code>    #ifndef MYAPP_H
      #define MYAPP_H
  
      #include &lt;QApplication&gt;
      #include &lt;QObject&gt;
  
      class MyApp : public QApplication
      {
      public:
          MyApp(QApplication &amp;app);
  
      protected:
           bool eventFilter(QObject *obj, QEvent *event);
      };
  
      #endif // MYAPP_H
  </code></pre>
  
  <p>myapp.cpp:</p>
  
  <pre><code>    #include "myapp.h"
      #include &lt;QEvent&gt;
  
      MyApp::MyApp(QApplication &amp;app) : QApplication(app)
      {
          installEventFilter(this);
      }
  
      bool MyApp::eventFilter(QObject *obj, QEvent *event)
      {
          if (event-&gt;type() == QEvent::ApplicationDeactivate)
          {
  
          }
  
          if (event-&gt;type() == QEvent::ApplicationDeactivate)
          {
  
          }
  
          else
          {
              return false;
          }
      }
  </code></pre>