[vtkusers] VTK+QTcreator

Jihan Zoghbi jihanzoghbi at gmail.com
Thu Sep 3 11:34:11 EDT 2009


Hi everybody,

I'm a beginner in using VTK with QTcreator. I pick up an example from the
Internet, which is the following.

The VTK.pro
=================================================================================

TARGET = VTK_App

TEMPLATE = app

 SOURCES += main.cpp\

vtk_example.cpp

HEADERS += vtk_example.h

FORMS += vtk_example.ui

LIBS += -L/usr/local/lib/vtk-5.4 -lvtkCommon -lvtksys -lQVTK -lvtkQtChart
-lvtkViews -lvtkWidgets -lvtkInfovis -lvtkRendering -lvtkGraphics
-lvtkImaging -lvtkIO -lvtkFiltering -lvtklibxml2 -lvtkDICOMParser -lvtkpng
-lvtkpng -lvtktiff -lvtkzlib -lvtkjpeg -lvtkalglib -lvtkexpat -lvtkverdict
-lvtkmetaio -lvtkNetCDF -lvtksqlite -lvtkexoIIc -lvtkftgl -lvtkfreetype
-lvtkHybrid

INCLUDEPATH +=/usr/local/VTK\
=========================================================================================
the main.cpp


 #include <QtGui/QApplication>

#include "vtk_example.h"

int main(int argc, char *argv[])

{

QApplication a(argc, argv);

VTK_example w;

w.show();

return a.exec();

}

====================================================================================================
vtk_example.cpp


#include <QVTKWidget.h>

#include <vtkRenderer.h>

#include <vtkRenderWindow.h>

#include "ui_vtk_example.h"

VTK_example::VTK_example(QWidget *parent)

: QMainWindow(parent), ui(new Ui::VTK_example)

{

ui->setupUi(this);

 QVTKWidget* vtkWidget;

vtkRenderer* ren;

vtkWidget = new QVTKWidget(this,QFlag(0));

ui->verticalLayout->addWidget(vtkWidget);

ui->verticalLayout->update();

ren = vtkRenderer::New();

vtkWidget->GetRenderWindow()->AddRenderer(ren);

ren->SetBackground(1.0,0,0);

ren->Render();

}

VTK_example::~VTK_example()

{

//delete ui;

}

===========================================================================================================
vtk_example.h

 #ifndef VTK_EXAMPLE_H

#define VTK_EXAMPLE_H

#include <QtGui/QMainWindow>

namespace Ui

{

class VTK_example;

}

class VTK_example : public QMainWindow

{

Q_OBJECT

public:

VTK_example(QWidget *parent = 0);

~VTK_example();

private:

Ui::VTK_example *ui;

};

#endif // VTK_EXAMPLE_H

==========================================
The program compile fine, but when I execute it, the following error is
shown:


""The program has unexpectedly finished.

VTK_App exited with code 0"'



Anybody has any idea about the error?


Any kind of help is appreciated.
-- 
Jihan Zoghbi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090903/8e4eaaaf/attachment.htm>


More information about the vtkusers mailing list