PDA

View Full Version : QVtkWidget under QTabWidget interactions are not working



Muhammad Jawad
11th May 2016, 15:16
Dear Qt Users,

I am facing a problem with QVtkWidget under QTabWidget. I have vtkImageViewer2 to bind with QVtkWidget and vtkInteractorStyleImage for the render window interactions.
QVtkWidget does not catch any event from keyboard or from mouse when I put QVtkWidget inside QTabWidget. But, If I use QVtkWidget outside QTabWidget then it's work fine.

I tried this code in MainWindow Constructor

QApplication::sendPostedEvents();
QApplication::processEvents(QEventLoop::AllEvents) ;

Also I tried, InstallEventFilter, still it is not working. Could you please guide me, what I need to do for proper interaction working ?


Best
Muhammad Jawad

d_stranz
11th May 2016, 17:09
I tried this code in MainWindow Constructor

Putting any sort of code like this in a main window constructor is useless, since there is no event loop running at the time the main window is being built. The event loop does not start running until after QApplication::exec() has been called from main().


Also I tried, InstallEventFilter, still it is not working.

Where? How? And what "is not working"? The event filter?

Muhammad Jawad
11th May 2016, 21:47
Here is my code:




vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
// this class is reimplemented from VtkInteractorStyleImage
vtkSmartPointer<MyVtkInteractorStyleImage> myInteractorStyle = vtkSmartPointer<MyVtkInteractorStyleImage>::New();

renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
myInteractorStyle->SetImageViewer(imageViewer);

imageViewer->SetupInteractor(renderWindowInteractor);

QVTKWidget *qvtkWidget = this->ptrMainWindow->GetQVtkWidget(viewerId);
qvtkWidget->SetRenderWindow(imageViewer->GetRenderWindow());
imageViewer->GetRenderer()->ResetCamera();
imageViewer->Render();
qvtkWidget->GetRenderWindow()->SetInteractor(imageViewer->GetRenderWindow()->GetInteractor());


When I use QVtkWidget as a mainwindow child then the interactions are working perfectly. But, I need to put three QVtkWidgets. So, I used QTabWidget inside mainwindow and put three QVtkWidgets in multiple tabs of QTabWidget. It load the data, but the interactions become jam.

Any help.

d_stranz
12th May 2016, 17:59
Sorry, but I don't know enough about vtk to help. Doesn't Kitware have a forum for vtk? You might be better off to post your question there.

Muhammad Jawad
13th May 2016, 11:52
But I think, this is not the problem at vtk side. It may be more on Qt side. But any way thanks for your time.