我是新来Qt的。我正在尝试将纹理添加到示例项目"basicshapes“中,它来自Qt Creator演示。它是用C++写的,很完美,因为这是我的需要。有一些常用的类,例如:
Qt3D::QTransform
Qt3D::QSphereMesh
Qt3D::QPhongMaterial和许多其他的,但我不知道如何添加纹理到它。有一个片段:
Qt3D::QPhongMaterial *sphereMaterial = new Qt3D::QPhongMaterial();
sphereMaterial->setDiffuse(QColor(QRgb(0xa69929)));所以我想补充一下:
MyTextureImage *t = new MyTextureImage();
MyTextureProvider *x = new MyTextureProvider();
x->addTextureImage(t);
sphereMaterial->setTextureParameter("SphereTexture", x);在我从抽象类派生之前:
class MyTextureProvider : public Qt3D::QAbstractTextureProvider { };
class MyTextureImage : public Qt3D::QAbstractTextureImage { };但是我得到了一个错误:
error: C2259: 'MyTextureImage' : cannot instantiate abstract class
due to following members:
'Qt3D::QNode *Qt3D::QNode::doClone(void) const' : is abstract发布于 2015-08-30 19:39:34
我不是Qt专家,但是通过查看编译器错误,您需要重写doClone方法,因为它被限定为纯虚拟的。
有关编译器错误的更多信息,请访问MSDN:https://msdn.microsoft.com/en-us/library/zxt206sk.aspx
我希望这能帮到你。
https://stackoverflow.com/questions/32296033
复制相似问题