Unsolved Share contentItem across Flickable s
-
Is there possible to share contentItem across Flickables? That we can save memory when using multiple Flickable s with the same contentItem.
-
@jiancaiyang One obvious solution (there may be others) is to use a ShaderEffectSource. The code below (works in qmlscene in Qt 5.9.1) gives you two independently flickable views of the
id: shared
item. No idea how inefficient it is (the extra framebuffers surely need a lot of memory; maybe some way of improving it using a targeted sourceRect?). Doesn't help in cases where you want to interact with the flicked content either (docs make it clear "The ShaderEffectSource type does not redirect any mouse or keyboard input to sourceItem.")import QtQuick 2.3 Rectangle { id: main width: 640 height: 480 Grid { id: shared rows: 10 columns: 10 Repeater { model: 100 Rectangle { width: 100 height: 100 color: Qt.rgba(Math.random(),Math.random(),Math.random(),1.0) } } } Row { Flickable { id: left width: 0.5*main.width height: main.height clip: true contentWidth: shared.width contentHeight: shared.height ShaderEffectSource { anchors.fill: parent sourceItem: shared hideSource: true } } Flickable { id: right width: 0.5*main.width height: main.height clip: true contentWidth: shared.width contentHeight: shared.height ShaderEffectSource { anchors.fill: parent sourceItem: shared hideSource: true } } } }
-
Maybe you can pass the mouse event to the sourceItem by yourself.