Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QQmlApplicationEngine failed to load component qrc:/main.qml: Invalid attached object assignment
QtWS25 Last Chance

QQmlApplicationEngine failed to load component qrc:/main.qml: Invalid attached object assignment

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 3.8k 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.
  • M Offline
    M Offline
    mhoggan
    wrote on last edited by
    #1

    Given my thoughts below am I barking up the wrong tree? Or provided the information below am I misusing the API to get the error in the title?

    I am trying to modify the sample at http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html 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).

    After looking through the code the first thing that stands out to me is:

    The samples main.cpp uses:
    @
    qmlRegisterType<Squircle>("OpenGLUnderQML", 1, 0, "Squircle");

    QQuickView view;
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl("qrc:///scenegraph/openglunderqml/main.qml"));
    view.show();
    

    @

    With some renaming my main.cpp uses

    @
    qmlRegisterType<MainScreen>("OpenGLUnderQML", 1, 0, "MainScreen");

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    

    @

    I am not sure if the difference in using a QQmlApplicationEngine over a QuickView could be causing my error:

    @
    QQmlApplicationEngine failed to load component
    qrc:/main.qml:23 Invalid attached object assignment
    @

    Where my main.qml looks like:

    @
    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
        }
    }
    

    }
    @

    and the sample uses:

    @
    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
    }
    

    }@

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Have you renamed the Squircle class to MainScreen ?

      157

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