Using QtimerEvent as Idle-function in QGraphicsScene
-
The timerEvent, which is a member of a QGLWidget class shall be triggered when the mousemove-function is called. I thought I could do it like this:
@void GLWidget::timerEvent(QTimerEvent *e)
{
if (e->timerId()==1 && refresh==true)
{
refresh = !refresh;
swapBuffers();
update();
}
}@It looks like this:
@void OpenGLScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
int mousex = event->scenePos().x();
int mousey = event->scenePos().y();if ((test->modus==2) && (test->move1 != -1)) { p_list[test->move1].x=mousex-(1220); p_list[test->move1].y=mousey-( 610); test->refresh = !(test->refresh); test->timerEvent(???); update(); }
}@
But somehow I dont know what to put into where the questions marks are. I have tried several things. It is not working. I want to set timerId()=1.I need the timer-function because it is an equivalent to the idle-function in OpenGL. Thanks for your help...
-
I don't understand what you're trying to do, fully. The timerEvent() isn't supposed to be called manually. You need to use QObject::startTimer() to set a timeout value. timerId() is the value returned by startTimer() when you activate the QObject's built-in timer.
-
Actually its working fine... I only had a minor problem with my coordinates.Thanks anyway