Trying to create a 3D Render of my object and put it into QWidget app, but I got some problem with transforming Q3DWidget into QWidget. I'm a novice in Qt and I'm sorry in advance for some ridiculous mistakes, if I have em. There is how I attempted to do it:
Qt3DExtras::Qt3DWindow view;
Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity;
Qt3DCore::QEntity *model = new Qt3DCore::QEntity(rootEntity);
Qt3DExtras::QPhongMaterial *material = new Qt3DExtras::QPhongMaterial();
material->setDiffuse(QColor(125, 125, 125));
Qt3DRender::QMesh *modelMesh = new Qt3DRender::QMesh;
QUrl data = QUrl::fromLocalFile("C:\\CDH\\model.stl");
modelMesh->setMeshName("Device model");
modelMesh->setSource(data);
model->addComponent(modelMesh);
model->addComponent(material);
Qt3DRender::QCamera *camera = view.camera();
camera->lens()->setPerspectiveProjection(40.0f, 16.0f/9.0f, 0.1f, 1000.0f);
camera->setPosition(QVector3D(0, 0, 40.0f));
camera->setViewCenter(QVector3D(0, 0, 0));
Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(rootEntity);
Qt3DRender::QPointLight *light = new Qt3DRender::QPointLight(lightEntity);
light->setColor("black");
light->setIntensity(0.8f);
lightEntity->addComponent(light);
Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity);
lightTransform->setTranslation(QVector3D(60, 0, 40.0f));
lightEntity->addComponent(lightTransform);
Qt3DExtras::QOrbitCameraController *camController = new
Qt3DExtras::QOrbitCameraController(rootEntity);
camController->setCamera(camera);
view.setRootEntity(rootEntity);
view.show();
QWidget *w = QWidget::createWindowContainer(&view);
//some widget handling
w->show();
It builds (MinGW 7.3.0) well, without errors and warning, but it just crashes when I try to launch an application.
Thanks in advance for your replies!