Hello,
I am facing some issues regarding the use of QQuickVTKInteractiveWidget to leverage VTK interactive widgets into QML application. For example, I am trying to use the vtkCameraOrientationWidget. The widget appears well in the viewport with the axis manipulator on the top right corner. However the axes are not responsive i.e. the camera view does not change when I click on each of the axis.
Here is a minimal example to reproduce:
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include “QQuickVTKInteractiveWidget.h”
#include “vtkCameraOrientationWidget.h”
#include “QQuickVTKRenderItem.h”
#include “QQuickVTKRenderWindow.h”
#include “vtkActor.h”
#include “vtkNew.h”
#include “vtkPolyDataMapper.h”
#include “vtkRenderer.h”
#include “vtkSphereSource.h”
int main(int argc, char* argv[])
{
QQuickVTKRenderWindow::setupGraphicsBackend();
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl("qrc:///TestQQuickVTKRenderItemWidget.qml"));
QObject* topLevel = engine.rootObjects().value(0);
QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel);
window->show();
vtkNew<vtkSphereSource> sphere;
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(sphere->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
QQuickVTKRenderItem* widgetItem = topLevel->findChild<QQuickVTKRenderItem*>("WidgetView");
widgetItem->renderer()->AddActor(actor);
widgetItem->update();
vtkNew<vtkCameraOrientationWidget> camWidget;
camWidget->SetParentRenderer(widgetItem->renderer());
camWidget->On();
QQuickVTKInteractiveWidget* qquickVTKWidget = new QQuickVTKInteractiveWidget(window);
qquickVTKWidget->setWidget(camWidget);
qquickVTKWidget->setEnabled(true);
widgetItem->addWidget(qquickVTKWidget);
widgetItem->update();
return QApplication::exec();}
Thanks in advance!