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. Types registered with qmlRegisterUncreatableType not available for properties
QtWS25 Last Chance

Types registered with qmlRegisterUncreatableType not available for properties

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.0k 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.
  • T Offline
    T Offline
    thorbjorn
    wrote on last edited by thorbjorn
    #1

    I'm trying to register a custom QML type that should not be created from QML, but I would really like to define properties with that type, mostly for the purposes of clarity and code completion. Unfortunately, it looks like types registered with qmlRegisterUncreatableType are not even available as properties:

    qmlRegisterUncreatableType<Model>("Model", 1, 0, "Model", "Model is created natively");
    

    And then doing this in QML:

    property Model model: null;
    

    Leads to the error "Model is created natively". But it does not make sense to me, since the above line is not trying to create an instance.

    Is this intentional or a possible bug in Qt?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by p3c0
      #2

      Hi,

      Taking a look at the attribute property documentation it makes sense that the type used for a property must be "creatable". A QML property implies the same rules as the Q_PROPERTYyou'd use on the C++ side.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Taking a look at the attribute property documentation it makes sense that the type used for a property must be "creatable". A QML property implies the same rules as the Q_PROPERTYyou'd use on the C++ side.

        T Offline
        T Offline
        thorbjorn
        wrote on last edited by
        #3

        @SGaist Hmm, but doesn't this translate to a pointer property? I'd expect the mapping to be:

        property string s;
        property Model m;
        
        Q_PROPERTY(QString s ...)
        Q_PROPERTY(Model *m ...)
        

        And the second really doesn't imply that Model needs to be creatable from QML. That would only be the case if I wrote this:

        Model {}
        
        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