QQuick(PaintedItem) inside a flickable



  • As follow up to this : http://qt-project.org/forums/viewthread/25805/

    I'm using a QQuickPaintedItem, drawing some lines.
    Now, I want to put it inside a flickable and update the drawing depending on the scroll position.
    I see that paint () is not called at each frame, so I don't know how to tell the item to repaint when the flickable scroll position is changed.

    (at the moment I tryed doing something like this, but seems a little weird)

    • have the QQuickPaintedItem "outside" the flickable, having it's size (anchors.fill : flickable)

    • draw the item each 300ms, via update()

    • bind the X position of the item to the flickable "contentX", so it basically scrolls the already-painted items without re-calling paint ()

    • everytime I trigger the timer , update the item () , and reset the X of the item to "0"

    If make the item bigger than the flickable, I can get a smooth scrolling without seeing the updates (though there is some flicker when the X position is reset).
    I feel this is not the correct way to do this!

    as an alternative option: is it possible to get an QSGNode low-level geometry out of a QPainter ? Maybe in this way I could transform the nodes depending on the contentX position, but I don't want to loose the QPainter benefits



  • I am also curious if there is a way to "borrow" the geometry QPainter generates when used on a OpenGL paint device, that could prove useful and save math headaches.


Log in to reply
 

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