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 :
void gldrawer
::keyPressEvent(QKeyEvent * event
) {
if(event->isAutoRepeat())
return;
if(_activeKeystates == 0)
qTimerRedraw.start(0);
for(KeyStates::iterator it = _keystates.begin();it != _keystates.end();
it++)
{
if (event->key() == it->first)
{
it->second = true;
_activeKeystates++;
break;
}
}
}
void gldrawer
::keyReleaseEvent(QKeyEvent * event
) {
for (KeyStates::iterator it = _keystates.begin();it != _keystates.end();
it++)
{
if (event->key() == it->first && !event->isAutoRepeat())
{
it->second = false;
_activeKeystates--;
break;
}
}
if(_activeKeystates == 0)
qTimerRedraw.stop();
}
void gldrawer::keyPressEvent(QKeyEvent * event)
{
if(event->isAutoRepeat())
return;
if(_activeKeystates == 0)
qTimerRedraw.start(0);
for(KeyStates::iterator it = _keystates.begin();it != _keystates.end();
it++)
{
if (event->key() == it->first)
{
it->second = true;
_activeKeystates++;
break;
}
}
}
void gldrawer::keyReleaseEvent(QKeyEvent * event)
{
for (KeyStates::iterator it = _keystates.begin();it != _keystates.end();
it++)
{
if (event->key() == it->first && !event->isAutoRepeat())
{
it->second = false;
_activeKeystates--;
break;
}
}
if(_activeKeystates == 0)
qTimerRedraw.stop();
}
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.
Bookmarks