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

A Qml warning is displayed in log when adding a Qml Item to a ListModel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.15.0, 5.15.2
    • None
    • Ubuntu 20.04
    • Linux/X11

    Description

      #include <QGuiApplication>
      #include <QQmlComponent>
      #include <QQmlEngine>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          QQmlEngine engine;
          QQmlComponent component(&engine);    
          component.setData(
                  R"(import QtQuick 2.15
                  Item {
                      width: 640
                      height: 480
                      ListModel {
                          id : model
                      }
                      Item {
                          id: a
                      }
                      Component.onCompleted: {
                           model.insert(0, a)
                      }
                  })",
                  QUrl());    
      
        QScopedPointer<QObject>(component.create());    
        return app.exec();
      }
      

      This warning is displayed in the log: "<Unknown File>: containmentMask is null. Adding an object with a null member does not create a role for it."
      Item.containmentMask is null by default so it automatically triggers this warning.

      Tested on Qt 5.12.0 and 5.12.2.

      (In the source code of 5.15.0, in /Src/qtdeclarative/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp, there is tst_qqmllistmodel::undefinedAppendShouldCauseError() for this warning)

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            fleroy Florian Leroy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes