0

I am new in Qt. I am trying to add texture to the example project "basicshapes", which comes from Qt Creator demo. It is written in C++ that'w perfect, because it is my need. There are used classes such as:

Qt3D::QTransform
Qt3D::QSphereMesh
Qt3D::QPhongMaterial

and many others but I can not realize how to add texture to it. There is a fragment:

Qt3D::QPhongMaterial *sphereMaterial = new Qt3D::QPhongMaterial();
sphereMaterial->setDiffuse(QColor(QRgb(0xa69929)));

so I was trying to add:

MyTextureImage *t = new MyTextureImage();
MyTextureProvider *x = new MyTextureProvider();
x->addTextureImage(t);
sphereMaterial->setTextureParameter("SphereTexture", x);

before I have derived from abstract classes:

class MyTextureProvider : public Qt3D::QAbstractTextureProvider { };
class MyTextureImage : public Qt3D::QAbstractTextureImage { };

but I got error:

error: C2259: 'MyTextureImage' : cannot instantiate abstract class
due to following members:
'Qt3D::QNode *Qt3D::QNode::doClone(void) const' : is abstract
user3057544
  • 807
  • 9
  • 22

1 Answers1

0

I am not an expert of Qt, however by looking at the compiler error, you would need to override the doClone method because it is qualified as pure virtual.

More information on your compiler error can be found on MSDN: https://msdn.microsoft.com/en-us/library/zxt206sk.aspx

I hope this helps.

KnightsWatch
  • 114
  • 6
  • how can I so override this method:class QT3DCORESHARED_EXPORT QNode : public QObject { ... private: virtual QNode *doClone() const = 0; ... }. I was trying: QNode *doClone() {} but the same error still occurs – user3057544 Aug 30 '15 at 13:14
  • you are missing the const qualifyer. Try: QNode *doClone() const {...} – KnightsWatch Aug 30 '15 at 13:26