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

Document how to use Qt Metatype system with types in C++ namespaces

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None

    Description

      Using custom namespaced types in signals, slots, invokables requires special care. From QTBUG-73761 :

      This is a known limitation of the current QMetaObject/QMetaType system, which do lookup by name.

      So the name (seen by moc) need to be be written the same in the Q_DECLARE_METATYPE, and in the Q_PROPERTY, and in the class definition.

      In Qt, we usually therefore fully qualify all types in Q_INVOKABLE, slot, and Q_PROPERTY signatures, as well as in qmlRegisterTypeXXX calls. ANyhow, this is only documented for Q_DECLARE_METATYPE:

      If MyStruct is in a namespace, the Q_DECLARE_METATYPE() macro has to be outside the namespace:

      Such advice should be added to the documentation of Q_INVOKABLE, Q_PROPERTY ... too. An overview section about this might be added e.g. to https://doc.qt.io/qt-5/metaobjects.html .

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              kkohne Kai Köhne
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes