Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

pause functionality in Qt using QTimer on button press

$
0
0
0 down vote favorite I am trying to implement pause button for a game I am developing in Qt + OpenGL. I want to implement it using QTimer. Basically I am updating screen per 100ms. So in order to pause game, I will stop the timer on button press. and when button is again pressed i will start the timer again Here is my pauseOrPlay SLOT: void Window::pauseOrPlay() {   GLWidget::modifyTimer = TRUE;   GLWidget::isPaused = !GLWidget::isPaused;     GLWidget  timerUpdater;   timerUpdater.timerFunc(); } and Here is my timerFunc() GLvoid GLWidget::timerFunc() {   static    QTimer *timer = new QTimer(this);   connect(timer, SIGNAL(timeout()), this, SLOT(update()));     if( GLWidget::isPaused)      timer->start(100);   else      timer->stop();   } But I am not getting the functionality. I get paused screen on this particular code and upon trying few tweaks here and there, sometimes I get screen updating very fastly which pointed me to this but I was unable to find cure to my problem somehow This maybe bit naive question about Qt, so may be I am missing something very basic. Any help or Pointers??

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>