[vtkusers] QVTKWidget crashes the entire Qt Application on click

John Eke johne at annidis.com
Sat May 31 13:35:02 EDT 2008


I figured out what was wrong. I had to manually override all the mouse event handlers, and left them empty to make sure nothing is done on each mouse event. And now it doesn't crash anymore. The handlers for the super class were pure virtual which caused the seg fault

-----Original Message-----
From: vtkusers-bounces at vtk.org on behalf of John Eke
Sent: Fri 5/30/2008 12:42 PM
To: vtkusers at vtk.org
Subject: [vtkusers] QVTKWidget crashes the entire Qt Application on click
 
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
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080531/d4f62b81/attachment.htm>


More information about the vtkusers mailing list