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

  • 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!

  • 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()) {

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.