Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] QT 5.2.0: Q_DECLARE_METATYPE requires value_type and other sequential class attributes to be defined

    General and Desktop
    1
    2
    1530
    Loading More Posts
    • 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.
    • J
      John.Curious last edited by

      I have a code that compiles and runs fine under QT 5.1.1. After upgrading to QT 5.2.0, I got errors:

      @
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1372) : error C2039: 'value_type' : is not a member of 'MyTemplateClass<T>'
      with
      [
      T=float
      ]
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1578) : see reference to class template instantiation 'QtPrivate::SequentialContainerConverterHelper<T>' being compiled
      with
      [
      T=MyTemplateClassFlt
      ]
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1600) : see reference to function template instantiation 'int qRegisterNormalizedMetaType<T>(const QByteArray &,T *,QtPrivate::MetaTypeDefinedHelper<T,defined>::DefinedType)' being compiled
      with
      [
      T=MyTemplateClassFlt,
      defined=true
      ]
      d:\users\vlad\vsprojects\qt\cmpt\libcc\libcct\MyTemplateClass.h(736) : see reference to function template instantiation 'int qRegisterMetaType<MyTemplateClassFlt>(const char *,T *,QtPrivate::MetaTypeDefinedHelper<T,defined>::DefinedType)' being compiled
      with
      [
      T=MyTemplateClassFlt,
      defined=true
      ]
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1372) : error C2146: syntax error : missing ',' before identifier 'value_type'
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1372) : error C2065: 'value_type' : undeclared identifier
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1382) : error C2955: 'QMetaTypeId2' : use of class template requires template argument list
      c:\qt\qt5.2.0\5.2.0\msvc2012_64\include\qtcore\qmetatype.h(1479) : see declaration of 'QMetaTypeId2'

      @
      These errors are generated from the line:
      @
      typedef MyTemplateClass<float> MyTemplateClassFlt; Q_DECLARE_METATYPE(MyTemplateClassFlt)
      @

      MyTemplateClass is a simple template class which is not based on a sequential container. Why 5.2.0's Q_DECLARE_METATYPE now requires "T::value_type" and other attributes of sequential classes?

      Is this a bug on 5.2.0 or my code is implicitly broken with undetectable under 5.1.1 problems?

      1 Reply Last reply Reply Quote 0
      • J
        John.Curious last edited by

        To leave this thread with an answer, it appeared that I was using Q_DECLARE_METATYPE_TEMPLATE_1ARG macro, which came quite handy to me, but that macro is not documented in QT and they changed its behavior, starting from 5.2.0.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post