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

Q_PROPERTY fails with qualified types

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.2.0
    • Fix Version/s: 5.3.0
    • Component/s: Build tools: moc
    • Labels:
      None
    • Environment:
      RHEL 6.5

      Description

      I have registered a non-QObject-derived class using:

      Q_DECLARE_METATYPE(mitk::DataStorage::Pointer)
      

      and

         qRegisterMetaType<mitk::DataStorage::Pointer>("mitk::DataStorage::Pointer");
      

      mitk::DataStorage::Pointer is a smart pointer defined like so:

      namespace mitk {
      
        class MITK_CORE_EXPORT DataStorage : public itk::Object
        {
        public:
          mitkClassMacro(DataStorage, itk::Object);
          // ...
         }
      }
      

      And mitkClassMacro defines the Pointer type:

      #define mitkClassMacro(className,SuperClassName) \
        typedef className        Self; \
        typedef SuperClassName      Superclass; \
        typedef itk::SmartPointer<Self> Pointer; \
        typedef itk::SmartPointer<const Self>  ConstPointer;
      

      The problem I'm encountering is when I try to use mitk::DataStorage::Pointer as a property. This fails to compile:

        Q_PROPERTY(mitk::DataStorage::Pointer dataStorage READ GetDataStorage WRITE SetDataStorage NOTIFY dataStorageChanged)
      

      With the error:

      'staticMetaObject' is not a member of 'mitk::DataStorage'
      

      "::Pointer" seems to get chopped off. Using this typedef workaround, it compiles fine:

        typedef mitk::DataStorage::Pointer mitkDataStoragePointer;
        Q_PROPERTY(mitkDataStoragePointer dataStorage READ GetDataStorage WRITE SetDataStorage NOTIFY dataStorageChanged)
      

        Attachments

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

          Activity

            People

            Assignee:
            ogoffart Olivier Goffart (Woboq GmbH)
            Reporter:
            nocnokneo Taylor Braun-Jones
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes