Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I implement a fixed update rate for a custom QDeclarative item?
Forum Updated to NodeBB v4.3 + New Features

How can I implement a fixed update rate for a custom QDeclarative item?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.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.
  • P Offline
    P Offline
    prismatic
    wrote on last edited by
    #1

    I have a custom QDeclarativeItem with a custom paint implementation. The paint implementation renders a 3d scene onto an FBO object. I'd like this 3d scene to be updated at fixed intervals as far as possible.

    Sometimes I receive a bunch of paint events in rapid succession. Since I'm drawing in OpenGL and using the FullViewportUpdate mode, I think this is unavoidable. In this case I try to repaint the contents of the fbo without updating the underlying scene.

    Sometimes I won't receive events for longer than the desired interval.

    Sometimes rendering the 3d scene will take longer than the desired interval.

    I'm having trouble figuring out an elegant way of dealing with all these cases that doesn't steadily increase the number of queued up events when my scene rendering slows down [which is what I think would happen if I just use a timer]. I'd appreciate any advice!

    1 Reply Last reply
    0
    • E Offline
      E Offline
      extronus
      wrote on last edited by
      #2

      Override QDeclarativeView::paintEvent(QPaintEvent *event) if you propogate the event to QDeclarativeView::paintEvent(event); it will paint, otherwise won't.

      @
      void my_class::paintEvent(QPaintEvent *event)
      {
      if (doIWantToRePaintTheScreen()) {
      QDeclarativeView::paintEvent(event);
      }
      else
      event->accept();
      }
      @

      Turgut Hakkı Özdemir

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prismatic
        wrote on last edited by
        #3

        This would affect the entire view though. I only want to control my custom item.

        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