Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. UpdateGL() with QTimer not working
Qt 6.11 is out! See what's new in the release blog

UpdateGL() with QTimer not working

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved