Important: Please read the Qt Code of Conduct -

migration from Qt 4.8 to Qt 5.0.2 qmetatype error

  • I just moved to Qt 5.0.2. I am developing app on embedded linux with linaro-gnueabihf toolchain and I am struggling with compile error:

                   from ../../cashless2_new/mgplayer/playlistdata.h:5,
                     from moc_playlistdata.cpp:9:
    ../../../Downloads/QT_build/5.02/include/QtCore/qmetatype.h: In instantiation of ‘int qMetaTypeId(T*) [with T = QVector<ResourceData*>*]’:
    ../../../Downloads/QT_build/5.02/include/QtCore/qmetatype.h:656:29:   required from ‘int qRegisterMetaType(T*) [with T = QVector<ResourceData*>*]’
    moc_playlistdata.cpp:144:95:   required from here
    ../../../Downloads/QT_build/5.02/include/QtCore/qmetatype.h:642:5: error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure<false>’
    make[1]: *** [moc_playlistdata.o] Error 1
    make[1]: Leaving directory `/home/nindza/TortoiseWork/build-cashless_app-new_A20_new-Release/mgplayer'
    make: *** [sub-mgplayer-make_first-ordered] Error 2
    18:07:47: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project cashless_app (kit: new A20)
    When executing step "Make"

    I tried to qRegisterMetaType<QVector<ResourceData*>>("QVector<ResourceData>"); in main or in ResourceData constructor and Q_DECLARE_METATYPE(QVector<ResourceData>*) outside ResourceData class declaraion in header, but nothing worked for me

    I am using slots and signals

    public slots:
        void setResources(QVector<ResourceData*>* arg);
        void resourcesChanged(QVector<ResourceData*>* arg);

    class declaration

    class class : public QObject

    QtCreator points error in qmetatype.h line 642 Q_STATIC_ASSERT_X

        Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
        return QMetaTypeId2<T>::qt_metatype_id();

    any idea what should I do?

    thanks for any help

    I am cross compiling on ubuntu 14 on arm device

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It seems you are not registering the same types you are using in your classes and you are trying to lie to the system.

    With Qt 5, remove the string from the qRegisterMetaType calls.

    On a side note, why 5.0.2 ? The current version of Qt is 5.8 with 5.9 hitting beta. If you need LTS then theres Qt 5.6.

Log in to reply