2

Qt 3DQCustomPlotライブラリの両方を使用する必要があるアプリケーションがあります。ただし、.pro ファイルで「QT += 3dinput」を使用してプロジェクトで QCustomPlot をコンパイルしようとすると、QMouseEventおよびQWheelEventクラスを参照するいくつかのエラーが表示されます。

これは、Qt3DInput が QtGui モジュールのQMouseEventおよびQWheelEventと同じ名前のクラスを導入しているという事実に関連していると思いますが、コンパイラ エラーが何を伝えようとしているのかを理解するには、Qt の内部動作に十分に精通していません。

この問題の正確な原因は何ですか?どうすれば回避できますか? .pro ファイルまたは QCustomPlot ライブラリ自体への変更は、どちらも許容されます。

問題を実証するには、次の .pro ファイルを使用して QCustomPlot をコンパイルします。

QT += widgets printsupport 3dinput
TEMPLATE = lib
SOURCES += qcustomplot.cpp
HEADERS += qcustomplot.h

次のエラーが発生します。

In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qnamespace.h:43:0,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/qobjectdefs.h:48,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:46,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
                 from debug\../../QCustomPlot/qcustomplot.h:29,
                 from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'constexpr int qMetaTypeId() [with T = QMouseEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26:   required from 'constexpr int qRegisterMetaType() [with T = QMouseEvent*]'
debug\moc_qcustomplot.cpp:2512:84:   required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qglobal.h:746:47: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
 #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
                                               ^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1745:5: note: in expansion of macro '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");
     ^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:54:0,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
                 from debug\../../QCustomPlot/qcustomplot.h:29,
                 from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QMouseEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1746:43:   required from 'constexpr int qMetaTypeId() [with T = QMouseEvent*]'
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26:   required from 'constexpr int qRegisterMetaType() [with T = QMouseEvent*]'
debug\moc_qcustomplot.cpp:2512:84:   required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:96: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QMouseEvent*>'
     static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
                                                                                                ^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:100: error: body of constexpr function 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QMouseEvent*]' not a return-statement
     static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
                                                                                                    ^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qnamespace.h:43:0,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/qobjectdefs.h:48,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:46,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
                 from debug\../../QCustomPlot/qcustomplot.h:29,
                 from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'constexpr int qMetaTypeId() [with T = QWheelEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26:   required from 'constexpr int qRegisterMetaType() [with T = QWheelEvent*]'
debug\moc_qcustomplot.cpp:2540:84:   required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qglobal.h:746:47: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
 #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
                                               ^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1745:5: note: in expansion of macro '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");
     ^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:54:0,
                 from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
                 from debug\../../QCustomPlot/qcustomplot.h:29,
                 from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QWheelEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1746:43:   required from 'constexpr int qMetaTypeId() [with T = QWheelEvent*]'
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26:   required from 'constexpr int qRegisterMetaType() [with T = QWheelEvent*]'
debug\moc_qcustomplot.cpp:2540:84:   required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:96: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QWheelEvent*>'
     static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
                                                                                                ^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:100: error: body of constexpr function 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QWheelEvent*]' not a return-statement
     static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
                                                                                                    ^

これは明らかに MinGW を使用していましたが、VC++ でも同様のエラーが発生します。

4

0 に答える 0