Hi everybody,<br><br>I'm a beginner in using VTK with QTcreator. I pick up an example from the Internet, which is the following.<br><br>The VTK.pro<br>=================================================================================<br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">TARGET = VTK_App</p>
<p style="margin: 0px; text-indent: 0px;">TEMPLATE = app</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">SOURCES += main.cpp\</p>
<p style="margin: 0px; text-indent: 0px;"> vtk_example.cpp</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">HEADERS += vtk_example.h</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">FORMS += vtk_example.ui</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">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</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">INCLUDEPATH +=/usr/local/VTK\</p>=========================================================================================<br>the main.cpp<br><br><br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;">#include <QtGui/QApplication></p>
<p style="margin: 0px; text-indent: 0px;">#include "vtk_example.h"</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">int main(int argc, char *argv[])</p>
<p style="margin: 0px; text-indent: 0px;">{</p>
<p style="margin: 0px; text-indent: 0px;"> QApplication a(argc, argv);</p>
<p style="margin: 0px; text-indent: 0px;"> VTK_example w;</p>
<p style="margin: 0px; text-indent: 0px;"> w.show();</p>
<p style="margin: 0px; text-indent: 0px;"> return a.exec();</p>
<p style="margin: 0px; text-indent: 0px;"> }</p>
<p style="margin: 0px; text-indent: 0px;"></p>====================================================================================================<br>vtk_example.cpp<br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">#include <QVTKWidget.h></p>
<p style="margin: 0px; text-indent: 0px;">#include <vtkRenderer.h></p>
<p style="margin: 0px; text-indent: 0px;">#include <vtkRenderWindow.h></p>
<p style="margin: 0px; text-indent: 0px;">#include "ui_vtk_example.h"</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">VTK_example::VTK_example(QWidget *parent)</p>
<p style="margin: 0px; text-indent: 0px;"> : QMainWindow(parent), ui(new Ui::VTK_example)</p>
<p style="margin: 0px; text-indent: 0px;">{</p>
<p style="margin: 0px; text-indent: 0px;"> ui->setupUi(this);</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;"> QVTKWidget* vtkWidget;</p>
<p style="margin: 0px; text-indent: 0px;"> vtkRenderer* ren;</p>
<p style="margin: 0px; text-indent: 0px;"> vtkWidget = new QVTKWidget(this,QFlag(0));</p>
<p style="margin: 0px; text-indent: 0px;"> ui->verticalLayout->addWidget(vtkWidget);</p>
<p style="margin: 0px; text-indent: 0px;"> ui->verticalLayout->update();</p>
<p style="margin: 0px; text-indent: 0px;"> ren = vtkRenderer::New();</p>
<p style="margin: 0px; text-indent: 0px;"> vtkWidget->GetRenderWindow()->AddRenderer(ren);</p>
<p style="margin: 0px; text-indent: 0px;"> ren->SetBackground(1.0,0,0);</p>
<p style="margin: 0px; text-indent: 0px;"> ren->Render();</p>
<p style="margin: 0px; text-indent: 0px;">}</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">VTK_example::~VTK_example()</p>
<p style="margin: 0px; text-indent: 0px;">{</p>
<p style="margin: 0px; text-indent: 0px;"> //delete ui;</p>
<p style="margin: 0px; text-indent: 0px;">}</p><br>===========================================================================================================<br>vtk_example.h<br><br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;">#ifndef VTK_EXAMPLE_H</p>
<p style="margin: 0px; text-indent: 0px;">#define VTK_EXAMPLE_H</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">#include <QtGui/QMainWindow></p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">namespace Ui</p>
<p style="margin: 0px; text-indent: 0px;">{</p>
<p style="margin: 0px; text-indent: 0px;"> class VTK_example;</p>
<p style="margin: 0px; text-indent: 0px;">}</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">class VTK_example : public QMainWindow</p>
<p style="margin: 0px; text-indent: 0px;">{</p>
<p style="margin: 0px; text-indent: 0px;"> Q_OBJECT</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">public:</p>
<p style="margin: 0px; text-indent: 0px;"> VTK_example(QWidget *parent = 0);</p>
<p style="margin: 0px; text-indent: 0px;"> ~VTK_example();</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">private:</p>
<p style="margin: 0px; text-indent: 0px;"> Ui::VTK_example *ui;</p>
<p style="margin: 0px; text-indent: 0px;">};</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">#endif // VTK_EXAMPLE_H</p><br>==========================================<br>The program compile fine, but when I execute it, the following error is shown:<br>
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">""The program has unexpectedly finished.</p>
<p style="margin: 0px; text-indent: 0px;"></p>
<p style="margin: 0px; text-indent: 0px;">VTK_App exited with code 0"'</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">
Anybody has any idea about the error?</p><p style="margin: 0px; text-indent: 0px;"><br></p><p style="margin: 0px; text-indent: 0px;">Any kind of help is appreciated.<br></p>-- <br>Jihan Zoghbi<br><br>