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 1I 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.
Thanks
David -
Hi,
Do you have have somewhere in your code a signal or slot that has a QList<QByteArray> pointer as a parameter ?
-
Use "Q_DECLARE_METATYPE":http://qt-project.org/doc/qt-5.0/qtcore/qmetatype.html#Q_DECLARE_METATYPE and "qRegisterMetatype":http://qt-project.org/doc/qt-5.0/qtcore/qmetatype.html#qRegisterMetaType and you should be good
-
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 [qt-project.org] and qRegisterMetatype [qt-project.org].
- May you give a small example of how to use them or refer some link where any example is given.
Thanks
Manoj -
Hi,
Here's an "example from the documentation":http://qt-project.org/doc/qt-5/custom-types.html
[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 ":http://qt-project.org/doc/qt-5.0/qtcore/queuedcustomtype.html -
This is a broken link.
[quote author="SGaist" date="1377550906"]Hi,
Here's an "example from the documentation":http://qt-project.org/doc/qt-5.0/qtcore/tools-customtype.html[/quote]
-
Thanks, the link has been updated