QTransform 包含 QtGui 和 Qt3D 之间的冲突

huangapple go评论66阅读模式
英文:

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::QTransformQtGui::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 &lt;QTransform&gt;

you need to include the package path in the include command

#include &lt;Qt3DCore/QTransform&gt;
#include &lt;QtGui/QTransform&gt;

and use Qt3DCore::QTransform and QtGui::QTransfrom in your code.

huangapple
  • 本文由 发表于 2023年6月16日 12:35:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76486978.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定