Hello,
I am using the QQMLvtkPlugin in my Qt Quick app. To do that the vtk documentation give the following example :
QQuickVTKRenderWindow::setupGraphicsBackend();
QGuiApplication app(argc, argv);
QQmlApplicaQtionEngine engine;
engine.load(QUrl("qrc:///<qmlfile>.qml"));
QObject* topLevel = engine.rootObjects().value(0);
QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel);
window->show();
// Fetch the QQuick window using the standard object name set up in the constructor
QQuickVTKRenderItem* qquickvtkItem = topLevel->findChild<QQuickVTKRenderItem*>("ConeView");
However, in my app I want to initialize my qquickvtkItem from my main.qml. In order to do that I have a singleton testQML wich allows me to create my scene:
ApplicationWindow {
id: appWindow;
readonly property SceneManage scene: TestQML.create(appWindow)
...
TestQML.create():
SceneManage *testQML::create(QQuickWindow *parent)
{
SceneManage *scene = new SceneManage(parent);
return scene;
}
But my app crashes when I do a window->show in the SceneManage constructor :
SceneManage::SceneManage(QObject *topLevel)
{
window = qobject_cast<QQuickWindow *>(topLevel); // QQuickWindow window
window->show();
QQuickItem *item = topLevel->findChild<QQuickItem *>("3DViewer");
...
Does someone have a way to solve this problem ? (The solution of the documentation and mine give the same adresses for window and the QQuickVTKRenderItem, so these are the right object)
Many thanks