Qt3DCore::QEntity* scene = new Qt3DCore::QEntity(); Qt3DCore::QEntity* ball = new Qt3DCore::QEntity(scene);ball->transform()->rotation(); 报'class Qt3DCore::QEntity' has no member named 'transform',怎么办
时间: 2024-01-21 21:17:38 浏览: 164
Qt3DAnimation_example2
报错提示"class Qt3DCore::QEntity' has no member named 'transform'"说明在Qt3DCore::QEntity中确实没有名为“transform”的成员。因此,你需要将ball强制转换为Qt3DCore::QTransform类型,然后再调用rotation()函数。可以尝试以下代码:
```
Qt3DCore::QEntity* scene = new Qt3DCore::QEntity();
Qt3DCore::QEntity* ball = new Qt3DCore::QEntity(scene);
Qt3DCore::QTransform* ballTransform = new Qt3DCore::QTransform();
ball->addComponent(ballTransform);
ballTransform->rotation();
```
这样就可以通过ballTransform对象来访问球的变换,并且调用rotation()函数来获得球的旋转。
阅读全文