UpdateGL() with QTimer not working
-
I have a problem with updating the OpenGL model on the screen. I use the timer to update the rotation angle every timer step:
@QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(Spin()));
timer->start(500);void GLWidget::Spin()
{
qDebug() << "Spin()";rotationX += 5; rotationY += 5; rotationZ += 5; updateGL();
}@
I also tried update() instead of updateGL() but it does not work either. The weird thing is, by rotating the model with the mouse it does work:
@void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
GLfloat dx = GLfloat(event->x() - lastPos.x()) / width();
GLfloat dy = GLfloat(event->y() - lastPos.y()) / height();
if (event->buttons() & Qt::LeftButton) {
rotationX += 180 * dy;
rotationY += 180 * dx;
updateGL();
} else if (event->buttons() & Qt::RightButton) {
rotationX += 180 * dy;
rotationZ += 180 * dx;
updateGL();
}
lastPos = event->pos();
}
@Can someone help me?