[vtkusers] How to use Qt Visual Studio Addin with VTK

John Anaia john.anaia at gmail.com
Sat Dec 31 18:15:46 EST 2011


Happy New Year to you all! Here is my development environment:

Windows Vista x64
VS 2008
VTK 5.6.1 x64, (compiled by myself, with Shared_Lib = ON)
QT 4.7.2 (LGPL, qt-win64-opensource-4.7.2-noqt3-vs2008.exe)
qt-vs-addin-1.1.10.exe

I installed and configured everything without any problems. While
compiling/building VTK from source, all Qt examples under
C:\VTK\VTKCode\Examples\GUI\Qt were built and run successfully. It looks
like I am ready to rock.

>From VS 2008, I created a Qt4 Project | Qt Applicaton, drag-and-dropped
QVTKWidget onto QMainWindow in Qt Designer. I could build and run this
simple example without any problem. However, after I added a vtkConeSource
to this QVTKWidget, I could not run my compiled MyTest.exe and got an error
message saying "MyTest.exe has stopped working". What am I missing here? I
added all LIBs to Additional Dependencies and all VTK DLLs are in PATH. I
am stuck here and could not move further. Please help! Thank you.

I copied vtkConeSource code from qtevent example as below:

MyTest::MyTest(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);

  // create a window to make it stereo capable and give it to QVTKWidget
  vtkRenderWindow* renwin = vtkRenderWindow::New();
  qvtkWidget->SetRenderWindow(renwin);
  renwin->Delete();

  const double angleSensitivity=0.02;
  const double translationSensitivity=0.001;

  QVTKInteractor *iren=qvtkWidget->GetInteractor();
  vtkInteractorStyle *s=
    static_cast<vtkInteractorStyle *>(iren->GetInteractorStyle());
  vtkTDxInteractorStyleCamera *t=
    static_cast<vtkTDxInteractorStyleCamera *>(s->GetTDxStyle());

  t->GetSettings()->SetAngleSensitivity(angleSensitivity);
  t->GetSettings()->SetTranslationXSensitivity(translationSensitivity);
  t->GetSettings()->SetTranslationYSensitivity(translationSensitivity);
  t->GetSettings()->SetTranslationZSensitivity(translationSensitivity);


  // add a renderer
  Ren1 = vtkRenderer::New();  # declared in header and deleted in destructor
  qvtkWidget->GetRenderWindow()->AddRenderer(Ren1);

  // put cone in one window
  vtkConeSource* cone = vtkConeSource::New();
  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
  mapper->SetInput(cone->GetOutput());
  vtkActor* actor = vtkActor::New();
  actor->SetMapper(mapper);
  Ren1->AddViewProp(actor);
  actor->Delete();
  mapper->Delete();
  cone->Delete();
}

Thanks a lot.
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111231/8a3173bb/attachment.htm>


More information about the vtkusers mailing list