Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Share contentItem across Flickable s
Qt 6.12 LTS is out! See what's new in the release blog

Share contentItem across Flickable s

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 1.4k Views
  • 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.
  • jiancaiyangJ Offline
    jiancaiyangJ Offline
    jiancaiyang
    wrote on last edited by
    #1

    Is there possible to share contentItem across Flickables? That we can save memory when using multiple Flickable s with the same contentItem.

    我们自己的论坛:http://qtdream.com
    擅长三维角色仿真动画。

    timdayT 1 Reply Last reply
    0
    • jiancaiyangJ jiancaiyang

      Is there possible to share contentItem across Flickables? That we can save memory when using multiple Flickable s with the same contentItem.

      timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      @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
            }
          }
        }
      
      }
      
      1 Reply Last reply
      0
      • D Offline
        D Offline
        dramasoft
        wrote on last edited by
        #3

        Maybe you can pass the mouse event to the sourceItem by yourself.

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