Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-43117

[regression] ShaderEffectSource should be able to duplicate content across Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.3.2, 5.4.0 RC, 5.6.0
    • Quick: SceneGraph
    • None
    • Windows 7 64-bit (MingW 32-bit, MSVC 64-bit) for 5.3 and 5.4 RC

    Description

      I would like to efficiently duplicate QML content across two windows without having to render the content twice. ShaderEffectSource has a really good way to do this BUT:

      Qt 5.3: You can see the duplicated content in different windows but you got the warning:
      qWarning("QQuickItem: Cannot use same item on different windows at the same time.");

      Qt 5.4: the shader effect source in the 2nd window doesn't even draw:
      ShaderEffectSource: sourceItem and ShaderEffectSource must both be children of the same window.

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          QQmlApplicationEngine engine;
      
          engine.load(QUrl(QStringLiteral("qrc:/Combined.qml")));
      
          return app.exec();
      }
      
      

      // Combined.qml

      import QtQuick 2.3
      import QtQuick.Controls 1.2
      import QtQuick.Window 2.2
      
      Item {
          width: 300
          height: 300
      
          Window {
              x: 500
              y: 100
              width: 640
              height: 480
              visible: true
      
              Item {
                  id: foo
                  width: 100; height: 100
                  Rectangle { id: rect; x: 5; y: 5; width: 60; height: 60; color: "red"
                      NumberAnimation { target: rect; property: "rotation"; duration: 1000;
                          from: 0
                          to: 360
                          easing.type: Easing.Linear
                          loops: Animation.Infinite
                          running: true
                      }
                  }
                  Rectangle { x: 20; y: 20; width: 60; height: 60; color: "orange" }
                  Rectangle { id: yellowRect; x: 35; y: 35; width: 60; height: 60; color:mouse.pressed ? "blue" : "yellow"
                      MouseArea {
                          id: mouse
                          anchors.fill: parent
                          drag {
                              target: parent
                              axis: Drag.XAndYAxis
                          }
                      }
                  }
              }
      
              // this shader effect source hides the foo item
              ShaderEffectSource {
                  width: 100; height: 100
                  sourceItem: foo
                  smooth: true
                  antialiasing: true
                  hideSource: true
              }
      
              // another shader effect source in the same window is OK
              ShaderEffectSource {
                  x: 200
                  width: 100; height: 100
                  sourceItem: foo
                  smooth: true
                  antialiasing: true
              }
          }
      
          // another window
          Window {
              x: 100
              y: 100
              width: 640
              height: 480
              visible: true
      
              // this shader effect source causes the windowRef count to exceed 1 and cause the warning:
              // Qt5.3: QQuickItem: Cannot use same item on different windows at the same time.
              // Qt5.4: ShaderEffectSource: sourceItem and ShaderEffectSource must both be children of the same window.
              ShaderEffectSource {
                  width: 100; height: 100
                  sourceItem: foo
                  smooth: true
                  antialiasing: true
              }
          }
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            miketrahearn Mike Trahearn
            Votes:
            5 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes