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

Provide a more detailed error message when a C++ type that's exposed to QML cannot be created

    XMLWordPrintable

Details

    Description

      When exposing a C++ type to QML (with e.g. QML_ELEMENT), it's possible to run into this error message:

      Element is not creatable.
      

      This means that the type cannot be created in C++. An example of this is forgetting to implement some virtual functions in an QAbstractItemModel subclass. It's not unusual for C++ types like models to be written purely for the sake of being exposed to QML, and hence never directly constructed in C++ in the application code.

      I think that the error message in this case should be more descriptive, even if a type not being creatable is valid C++ (e.g. intentionally missing a constructor or unimplemented virtual functions for classes that are intended to be subclassed). For example:

      Type Foo is not creatable because QQuickFoo is an abstract type.
      

      Attachments

        Issue Links

          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
              mitch_curtis Mitch Curtis
              Votes:
              3 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes