英文:
QTransform Include conflict between QtGui and Qt3D
问题
我正在使用 Qt 5.15.2 和 qmake 构建系统来开发项目。我已经通过在 .pro
文件中添加 Qt += 3dcore 3drender
来包含 Qt3D。
在构建项目时,我从 qgeoprojection_p.h
的第121行收到以下错误信息:
field 'm_itemToWindowTransform' has incomplete type 'QTransform'
据我所知,qgeoprojection_p.h
文件在解析 #include <QTransform>
时存在问题,它使用了 Qt3D 内部定义的 QTransform
,而不是 GUI 组件中的。
我已经报告了一个 Qt bug 给他们。
如何解决这个问题并在我的项目中使用 Qt3D?
英文:
I am using Qt 5.15.2 and the qmake build system for the project. I have included Qt3D by adding Qt += 3dcore 3drender
in the .pro
file.
When building the project, I get this error from qgeoprojection_p.h
, line 121:
field 'm_itemToWindowTransform' has incomplete type 'QTransform'
As far as I know, the qgeoprojection_p.h
file is having issues with resolving #include <QTransform>
and its using the QTransform
defined inside the Qt3D instead of the GUI component.
I have raised a Qt bug for this.
How to get past this and use Qt3D in my project?
答案1
得分: 2
很抱歉,Qt在不同的包中提供了具有相同名称的不同类。为了解决这个问题,您需要明确指定您想要使用的那个类,即不要使用以下方式:
#include <QTransform>
而是需要在包路径中包含include命令:
#include <Qt3DCore/QTransform>
#include <QtGui/QTransform>
并在您的代码中使用 Qt3DCore::QTransform
和 QtGui::QTransform
。
英文:
Unfortunately Qt provides different classes with the same name in different packages. To resolve this issue you need to explicitely specify which one you want to use, i.e. instead of doing
#include <QTransform>
you need to include the package path in the include command
#include <Qt3DCore/QTransform>
#include <QtGui/QTransform>
and use Qt3DCore::QTransform
and QtGui::QTransfrom
in your code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论