title: QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment
body: <p>Given my thoughts below am I barking up the wrong tree? Or provided the information below am I misusing Qt API to get the error in the title?</p>
  
  <p>I am trying to modify the sample at <a href="http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html" rel="nofollow">http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html</a> to work with the default QtQuick project generated with Qt Creator 3.3.0 (opensource)
  Based on Qt 5.4.0 (GCC 4.6.1, 64 bit).</p>
  
  <p>After looking through the code the first thing that stands out to me is:</p>
  
  <p>The samples main.cpp uses:</p>
  
  <pre><code>qmlRegisterType&lt;Squircle&gt;("OpenGLUnderQML", 1, 0, "Squircle");
  
  QQuickView view;
  view.setResizeMode(QQuickView::SizeRootObjectToView);
  view.setSource(QUrl("qrc:///scenegraph/openglunderqml/main.qml"));
  view.show();
  </code></pre>
  
  <p>With some renaming my main.cpp uses</p>
  
  <pre><code>qmlRegisterType&lt;MainScreen&gt;("OpenGLUnderQML", 1, 0, "MainScreen");
  
  QQmlApplicationEngine engine;
  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  </code></pre>
  
  <p>I am not sure if the difference in using a QQmlApplicationEngine over a QuickView could be causing my error:</p>
  
  <blockquote>
    <p>QQmlApplicationEngine failed to load component qrc:/main.qml:23<br>
    Invalid attached object assignment</p>
  </blockquote>
  
  <p>Where my main.qml looks like:</p>
  
  <pre><code>import QtQuick 2.4
  import QtQuick.Window 2.2
  import OpenGLUnderQML 1.0
  import "qmlmodel"
  
  Window {
      id: mainWindow
      width: 800
      height: 600
      visible: true
      color: "black"
      title: "Army Calculator"
      objectName: "mainWindow"
  
      ListView {
          id: mainListView
          anchors.fill: parent
          objectName: "mainListView"
      }
  
      MainScreen {
          SequentialAnimation on DeltaT {
              NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
              NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
              loops: Animation.Infinite
              running: true
          }
      }
  }
  </code></pre>
  
  <p>and the sample uses:</p>
  
  <pre><code>import QtQuick 2.0
  import OpenGLUnderQML 1.0
  
  Item {
  
      width: 320
      height: 480
  
      Squircle {
          SequentialAnimation on t {
              NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
              NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
              loops: Animation.Infinite
              running: true
          }
      }
      Rectangle {
          color: Qt.rgba(1, 1, 1, 0.7)
          radius: 10
          border.width: 1
          border.color: "white"
          anchors.fill: label
          anchors.margins: -10
      }
  
      Text {
          id: label
          color: "black"
          wrapMode: Text.WordWrap
          text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
          anchors.right: parent.right
          anchors.left: parent.left
          anchors.bottom: parent.bottom
          anchors.margins: 20
      }
  }
  </code></pre>
  
  <hr>
  
  <p>As per request in comment below MainScreen.h is</p>
  
  <pre><code>#ifndef MAINSCREEN_H
  #define MAINSCREEN_H
  
  #include &lt;QQuickItem&gt;
  
  class MainScreenRenderer;
  class QQuickWindow;
  
  class MainScreen : public QQuickItem
  {
      Q_OBJECT
      Q_PROPERTY(qreal DeltaT READ getDeltaT WRITE setDeltaT NOTIFY deltaTChanged)
  
  public:
      MainScreen();
      ~MainScreen();
  
      qreal getDeltaT() const;
      void setDeltaT(qreal deltaT);
  
  signals:
      void deltaTChanged();
  
  public slots:
      void sync();
      void cleanup();
  
  private slots:
      void handleWindowChanged(QQuickWindow *win);
  
  private:
      qreal m_DeltaT;
      MainScreenRenderer *m_Renderer;
  };
  
  
  #endif // MAINSCREEN_H
  </code></pre>