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

Uncreatable C++ type can't be used for QML property types

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.8.0
    • 5.0.0, 5.1.0 , 5.2.0, 5.2.1
    • None
    • Linux Ubuntu 13.04 32 bit, Qt 5.2.1, Clang 3.3 / GCC 4.7.3

    Description

      When exposing a custom C++ QObject-derived type to QML engine using :

      qmlRegisterUncreatableType<MyClass>("MyModule", 1, 0, "MyClass", "My error !");

      We are not able to instanciate it in QML, and that's normal.
      What isn't is that we can't even use the type for a QML property :

      property MyClass myProp : null;

      Will throw "My error !"

      That's definitely not normal behavior, even if type can't be instanciated in QML we should be able to affect a pointer to this type to a strongly type property in QML, without having to use QtObject type.

      Because by using QtObject instead of MyClass we allow to put almost anything in the property, what we don't want, and as a side effect, we lose auto-completion for the property sub-properties.

      Please fix it soon, we don't like using creatable types just to be able to affect a pointer to a property, that's not safe at all. Even more, it's sometimes hard to make an uncreatable class registrable with qmlRegisterType instead of qmlRegisterUncreatableType because it implies heavy modifications of the constructor...

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            thebootroo Thomas Boutroue
            Votes:
            9 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes