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. Using QtimerEvent as Idle-function in QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

Using QtimerEvent as Idle-function in QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k 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.
  • B Offline
    B Offline
    basil_fawlty
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      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.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        basil_fawlty
        wrote on last edited by
        #3

        Actually its working fine... I only had a minor problem with my coordinates.Thanks anyway

        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