Can I reload/refresh 3d model on mouse click?

  • Hi All,

    I am developing a 3d model loader in Qt 5.7 on Windows.
    I have been successful in loading the model. The model has jpg textures.
    I want to be able to reload the model (say, on a button click), whenever I replace the texture image on disk.

    Here is the code that loads the model,

    ASErr RenderView()
    	// Root entity
    	Qt3DCore::QEntity *sceneRoot = new Qt3DCore::QEntity();
    	// Scene Camera
    	Qt3DRender::QCamera *camera = view->camera();
    	camera->setAspectRatio(view->width() / view->height());
    	camera->setUpVector(QVector3D(0.0f, 1.0f, 0.0f));
    	camera->setViewCenter(QVector3D(0.0f, 1.1f, 0.0f));
    	camera->setPosition(QVector3D(0.0f, 2.5f, 2.0f));
    	// For camera controls
    	Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(sceneRoot);
    	// Scene loader
    	Qt3DCore::QEntity *sceneLoaderEntity = new Qt3DCore::QEntity(sceneRoot);
    	Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(sceneLoaderEntity);
    	sceneWalker = new SceneWalker(sceneLoader);
    	QObject::connect(sceneLoader, &Qt3DRender::QSceneLoader::statusChanged, sceneWalker, &SceneWalker::onStatusChanged);
    	std::string url = GetUrl();
    	QUrl sourceFileName(url.c_str());
    	if (sourceFileName.isEmpty())
    		return 0;
    	return 0;

    Here, view is a pointer to Qt3DExtras::Qt3DWindow.
    I have followed the assimp-cpp sample from Qt.

    How can I refresh my model on button click so that it refreshes the textures?

  • Update:
    When I try to call the above method after the texture jpg image is changed, I get the following exception,

    ASSERT: "!is Visible()" in file defaults\qt3d window.cpp
    on this line,


    How can I refresh the model view?

  • Anyone?
    Please guide.
    I really need to understand this.

  • hi did u fix it ,i also encout this problem when delete or add a 3DObject to QT3DWindow.. it seems have no convnient api to do this