Important: Please read the Qt Code of Conduct -

C++ to QML Export: "Cannot assign object to list"

  • Edit: To my surprise it works as a release build but the issue is still present in any debug build I am doing. Release build works without any changes... Did anyone experience something like that?

    I am currently moving from Qt4.8,1 to Qt5.5.0 and I am facing a serious problem with the elements I am exporting from C++ to QML. It (still) uses the old way using QDeclarativeItem to export the UI elements to QML. At the moment I can't use QtQuick2 because part of the application heavily relies on QGraphicsView and worse: QGraphicsScene. So I still have to stick with the QDeclarative stuff which should still work with Qt5.5.

    I am doing everything as with Qt4.8.1 that is: creating the UI elements as QDeclarativeItems in C++ and register them in QML with qmlRegisterType< >. Everything is compiled nicely and the import statement in the QML files don't show errors. I can start the application and all pure qml elements are rendered and do what they are supposed to do.

    BUT: The elements exported from C++ can not be created. It is always states that "Cannot assign object to list" in the line in which such an element is created. I found a blog entry from Lewis Manor ( in which he describes the same error message and found that a qRegisterMetaData<QObject*>("foo") destroyed the MetaSystem. So I searched for any similar error but could not find one. I even disabled all qRegisterMetaData and qmlRegisterType stuff except the one element I want to create. Still the same issue.

    Can anyone help please??

    Out of desparation I also posted this in the [Interest] mailing list . Appologies for this double posting.

  • Even your application relies on QGraphicsView and QGraphicsScene, you can still use QtQuick2. Try to use QQuickWidget instead of QDeclarativeView.

  • @NCsoft
    Thank you for this hint, I will try that as well. I am still struggeling with the error I initially reported. I did a minimal example which is a main function which only creates a QQuickView(1)or a QDeclarativeView(2) and loads a minimal main.qml file with only a text element and a QQuickPaintedItem(1) or a QDeclarativeItem(2). QQuickPaintedItem(1) or QDeclarativeItem(2) are exportet inside a QQmlExtensionPlugin(1) or a QDeclarativExtensionPlugin(2)

    Both versions do not work.
    (1) Fails to load QtQuick, module is not known and does not load the exported QQuickPaintedItem
    (2) Fails to load exported QDeclarativeItem but can load pure qml types such as Text{}

    Meanwhile I assume that something with my installation is wrong, but I can't figure out what. All loaded dlls are correct and I removed all old installations of Qt and QtCreator and removed everything from the PATH which could load a Qt dll.

    I am using Qt 5.5.0 and QtCreator 3.6.1, building with Visual Studio 2013 on Windows 7

    Running out of ideas...

Log in to reply