Results 1 to 6 of 6

Thread: QTimer ->start(0) + OpenGL + resize/move window => crash

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: QTimer ->start(0) + OpenGL + resize/move window => crash

    Quote Originally Posted by anthibug View Post
    elapsed_time = (current_time.second()*1000 + current_time.msec()) - (last_time.second()*1000 + last_time.msec());
    Take a look at QTime::msecsTo().

  2. #2
    Join Date
    Jul 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 1 Time in 1 Post

    Default Re: QTimer ->start(0) + OpenGL + resize/move window => crash

    Thanks jacek, I missed it !

    Thanks spud you got the idea : a timer to refresh the scene if their is still a pressed key....
    I managed to do this with minor modifications :

    Qt Code:
    1. void gldrawer::keyPressEvent(QKeyEvent * event)
    2. {
    3. if(event->isAutoRepeat())
    4. return;
    5. if(_activeKeystates == 0)
    6. qTimerRedraw.start(0);
    7. for(KeyStates::iterator it = _keystates.begin();it != _keystates.end();
    8. it++)
    9. {
    10. if (event->key() == it->first)
    11. {
    12. it->second = true;
    13. _activeKeystates++;
    14.  
    15. break;
    16. }
    17. }
    18. }
    19.  
    20. void gldrawer::keyReleaseEvent(QKeyEvent * event)
    21. {
    22. for (KeyStates::iterator it = _keystates.begin();it != _keystates.end();
    23. it++)
    24. {
    25. if (event->key() == it->first && !event->isAutoRepeat())
    26. {
    27. it->second = false;
    28. _activeKeystates--;
    29. break;
    30. }
    31. }
    32. if(_activeKeystates == 0)
    33. qTimerRedraw.stop();
    34. }
    To copy to clipboard, switch view to plain text mode 

    where _keystates is a std::map<Qt::Key, bool> (yes I know I could use QMap, I will ...)

    Right now CPU is at 0%.
    If I push a key (and stay pushed) the scene is continously refreshed : one core is at 100%.
    I can push keys with modifiers :-)

    Thanks !


    ----


    I'm currently having problems dealing with QSlider :
    I have to repaint the scene during a call to my slot corresponding to the "valueChanged" signal of the QSlider. The problem is that it's make the slider freeze/lag.
    In can understand that because each time I move the slider it redraws the scene, and that takes time.
    The scene is updated in real time according to the position of the slider, but the position of the slider itself is lagging (juste visually)...
    Could be a user issue in the future.
    I tried the "sliderReleased()" but the problem is that the scene is not updated in real time.
    Last edited by anthibug; 7th July 2008 at 15:32.

  3. #3
    Join Date
    Jul 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 1 Time in 1 Post

    Default Re: QTimer ->start(0) + OpenGL + resize/move window => crash

    I managed to do that the same way I did with the keys :
    -if the QSlider is moved then repaint (qTimerRedraw.start(0)
    -when released stop to repaint

    ... so easy

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
  •  
Qt is a trademark of The Qt Company.