QScrollArea in Qml: Flickable + QQuickPaintedItem



  • I'm trying to realize something similiar to QScrollArea (in widgets world) with the help of Qml.
    I decided to probe Flickable plus QQuickPaintedItem based item (named Drawer in my case):

    Flickable {
      ...
      onContentXChanged(): {
      drawer.update()
      }
    
    Drawer {
      id: drawer
      ...
    }
    

    Drawer's render target is set to FrameBufferObject. Its paint function looks like this:

    void Drawer::paint(QPainter *painter)
    {
       // Some function to compute rect which is needed to be redrawn
       QRect updateRect = computeUpdateRect();
    
       // How to shift contents of Frame buffer, e.g. to right, and draw only updateRect in this space?
    }
    

    Imagine how we do scrolling in QScrollArea widget, e.g. to left: all entry of viewport is shifted to right and the only small rect in left is redrawn.
    I want to do the same with Flickable+QQuickPaintedItem. But I can't understand some things:

    1. How can I manipulate Frame Buffer object inside QQuickPaintedItem?
    2. Maybe there is some more right way to implement QScrollArea in QML?

    By the way, is double buffering enabled by default in QQuickPaintedItem?