[vtkusers] QVTKWidget crashes the entire Qt Application on click
John Eke
johne at annidis.com
Fri May 30 12:42:22 EDT 2008
Hello People,
I have a main QWidget, inside which I have added QVTKWidgets. I was
wondering what the propper way was to initialize QVTKInteractors so that
everything works fine. The way I have it setup right now, everything
loads fine, but once I click on the QVTKWidgets, the entire app crashes
with a seg fault error.
Heres an example of what I am doing, these are called from within the
constructor of a subclass of the QVTKWidget:
//initialize member variables
m_pImageActor = vtkImageActor::New();
m_pRenderer = vtkRenderer::New();
//add renderer
m_pRenderer->SetBackground(0.0, 0.0, 0.0);
GetRenderWindow()->AddRenderer(m_pRenderer);
GetRenderWindow()->Render();
//load an image using ITK
typedef itk::Image<unsigned char,2> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
ReaderType::Pointer reader = ReaderType::New();
ConnectorType::Pointer connector = ConnectorType::New();
//read image and pass it onto the image actor
reader->SetFileName("temp.png");
connector->SetInput (reader->GetOutput());
m_pImageActor->SetInput(connector->GetOutput());
//add the image actor to the renderer
m_pRenderer->AddActor(m_pImageActor);
When I do this, all loads well, but when I click on the QVTKWidget, the
app crashes with a segmentation fault error. I am assuming maybe I am
not properly initializing the QVTKInteractor. GetInteractor() gives me
the QVTKInteractor and SetInteractor() sets it right back. So I am
assuming the default constructor has already initialized the QVTKInteractor.
Any thoughts/ideas/help will be greatly appreciated!
Thanks
- John
More information about the vtkusers
mailing list