[vtkusers] Problems with vtkImageViewer2 when using with QVTKWidget

Luca Pamparana deluded.soul at gmail.com
Thu Jul 27 08:16:43 EDT 2006


Hi everyone,

I have a problem with vtkImageViewer2 when trying to use it with a
QVTKWidget. The puzzling thing is that the same code when used with
vtkImageViewer works fine.

I was wondering if someone has any ideas as to what I am doing wrong:

Here is the code:

QApplication app(argc, argv);
 MainWindow mainWin;

 QTVTKWidget widget;

    #if QT_VERSION < 0x040000
        app.setMainWidget(&mainWin);
    #endif

        // DICOM image reader

        vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
        reader->SetDirectoryName("/home/luca/data/dicom/11088");
        reader->Update();

        vtkImageViewer2 * view2 = vtkImageViewer2::New();
        view2->SetInput(reader->GetOutput());

        double * range = reader->GetOutput()->GetScalarRange();
        view2->SetColorLevel (0.5 * (range[1] + range[0]));
        view2->SetColorWindow (range[1] - range[0]);

        // We will have out custom interactor later
        view2->SetupInteractor(widget.GetRenderWindow()->GetInteractor());
        widget.SetRenderWindow(view2->GetRenderWindow());

        QVBoxLayout * mainLayout = new QVBoxLayout;
        mainLayout->addWidget(&widget);
        mainWin.addLayout(mainLayout);

        mainWin.Pack();
        mainWin.show();
        // Run our application loop.
        app.exec();


Now, this only shows a blank black canvas with no image...and if I replace
the ctkImageViewer2 with vtkImageViewer object, it works fine...


I am not sure what I am doing wrong... any help would be appreciated...

Cheers,
Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060727/2437adb6/attachment.htm>


More information about the vtkusers mailing list