Compile bug porting fromQt4 to Qt5

  • It wasn't very difficult, but it was tedious to adjust my code for all of the subtle changes in methods, and others not so subtle (Phonon disappearing) necessary for Qt5.

    After it compiles hundreds of files some of which are put into libs, it craps out on trying to compile a moc genearted file. This file is my main appliation and inherrits from QMainWindow. Here is the output

    bq. In file included from /opt/Qt5.0.2/5.0.2/gcc/include/QtCore/qobject.h:55:0,
    from /opt/Qt5.0.2/5.0.2/gcc/include/QtWidgets/qwidget.h:46,
    from /opt/Qt5.0.2/5.0.2/gcc/include/QtWidgets/qmainwindow.h:45,
    from /opt/Qt5.0.2/5.0.2/gcc/include/QtWidgets/QMainWindow:1,
    from .moc/../TickEdge.h:12,
    from .moc/moc_TickEdge.cpp:9:
    /opt/Qt5.0.2/5.0.2/gcc/include/QtCore/qmetatype.h: In instantiation of ‘int qMetaTypeId(T*) [with T = QList<QByteArray>]’:
    /opt/Qt5.0.2/5.0.2/gcc/include/QtCore/qmetatype.h:656:29: required from ‘int qRegisterMetaType(T
    ) [with T = QList<QByteArray>*]’
    .moc/moc_TickEdge.cpp:805:90: required from here
    /opt/Qt5.0.2/5.0.2/gcc/include/QtCore/qmetatype.h:642:5: error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure<false>’
    make[1]: *** [.obj/moc_TickEdge.o] Error 1

    I tried to follow the example in Qt 5..0.2 widgets/mainwindow which does compile correctly.

    And in my .pro file I have:

    QT += widgets script network sql webkit declarative help http

    Note the offending line reported above is
    #include <QMainWindow>

    Any help here appreciated.


  • Lifetime Qt Champion


    Do you have have somewhere in your code a signal or slot that has a QList<QByteArray> pointer as a parameter ?

  • Hi SGaist.

    Thank you for the reply. Yes, it was not in the offending moc file, but I do see that I make use of a QList<QByteArray>. I guess I have to register this type, but not sure how as of yet. Any hints ?

    Thanks again

  • Lifetime Qt Champion

  • Ok, will give it a try when the work day ends. I really apprciate you taking the time to help here.

  • Hi,
    I'm having this exact same problem too.
    I'm also using QList<QByteArray> in my code, but not as a parameter to any signal or slot.
    Can you please explain what the problem with QList<QByteArray> is and how can I fix this?

    Edit: I just looked at my compile output and I think the problem on my side is actually in these 2 lines:
    ......\Tools\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qmetatype.h: In instantiation of 'int qMetaTypeId(T*) [with T = QList<TRSite*>]':
    ......\Tools\Qt\Qt5.0.2\5.0.2\mingw47_32\include/QtCore/qmetatype.h:656:29: required from 'int qRegisterMetaType(T
    ) [with T = QList<TRSite*>*]'

    I have in my mainwindow.h the following:
    QList<TRSite*> list[10];

    But I have no idea why it is not compiling. Any suggestions what should I do?

  • Hi, in which case your QList<TRSite*> list is used? QVariant/ Property/ signal and slots?

    If so, you should use Q_DECLARE_METATYPE and qRegisterMetatype to declare and register it.

  • Hi SGaist
    I am also facing the same issue too.

    @In file included from moc_ThreadController.cpp:9:0:
    ../TestCartetionProduct/ThreadController.h:52:30: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
    In file included from ../../../Qt5.0.2/5.0.2/gcc_64/include/QtCore/qobject.h:55:0,
    from ../../../Qt5.0.2/5.0.2/gcc_64/include/QtCore/QObject:1,
    from ../TestCartetionProduct/ThreadController.h:4,
    from moc_ThreadController.cpp:9:
    ../../../Qt5.0.2/5.0.2/gcc_64/include/QtCore/qmetatype.h: In instantiation of 'int qMetaTypeId(T*) [with T = QVector<BaseMassSpectrumDTO*>]':
    ../../../Qt5.0.2/5.0.2/gcc_64/include/QtCore/qmetatype.h:656:29: required from 'int qRegisterMetaType(T
    ) [with T = QVector<BaseMassSpectrumDTO*>*]'
    moc_ThreadController.cpp:96:102: required from here
    ../../../Qt5.0.2/5.0.2/gcc_64/include/QtCore/qmetatype.h:642:5: error: invalid application of 'sizeof' to incomplete type 'QStaticAssertFailure<false>'
    make: *** [moc_ThreadController.o] Error 1
    22:00:07: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project TestCartetionProduct (kit: Desktop Qt 5.0.2 GCC 64bit)
    When executing step 'Make'@

    I am not able to follow up documentation of Q_DECLARE_METATYPE [] and qRegisterMetatype [].

    • May you give a small example of how to use them or refer some link where any example is given.


  • Lifetime Qt Champion


    Here's an "example from the documentation":

    [edit: corrected link for latest current documentation: 5.3]

  • Thanks SGaist, Its worked for me :)
    This link also helped me to understand how to use signal/slot with the container classes and multi-threading "Queued Custom Type Example ":

  • This is a broken link.

    [quote author="SGaist" date="1377550906"]Hi,

    Here's an "example from the documentation":[/quote]

  • Lifetime Qt Champion

    Thanks, the link has been updated

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.