I am working at a part of a big project.
My goal is it to show a vtkRenderer
in a QWidget
. For that I wrote this class:
CModelViewWidget::CModelViewWidget(QWidget *parent) :
QWidget(parent)
{
_qVtkWidget = new QVTKWidget(this,Qt::Widget);
_rend = vtkRenderer::New();
this->showVTK();
_qVtkWidget->GetRenderWindow()->AddRenderer(_rend);
}
where _qVtkWidget
is a QVTKWidget
, _rend
a vtkRenderer
and showVTK()
a function that adds a sphere to _rend
.
I am able to compile this things, but when I want to test them the program crashes. The error message is:
[pathToProject]/qtCT/qtcreator-build/bin/mabviewer: symbol lookup error:[pathToProject]/qtCT/qtcreator-build/lib/libplugwdgt_modelviz.so: undefined symbol: _ZN10QVTKWidgetC1EP7QWidget6QFlagsIN2Qt10WindowTypeEE
I am using VTK5.8, QTCreator 2.4.1 with QT 4.7.4 and cmake. I linked the project and VTK and showing a normal vtkRenderWindow
works fine. Is there something else to do, before QVTKWidget
works?
My setup is a little different, but the code works. Setup: Qt x64 4.8.4 and VTK 5.10, using VS2010 x64 compiler.
First, add a verticalLayout widget to the main UI screen. I suppose any of the other layouts would work, but I haven't tried them. In the C++ editor try:
_qvtkWidget = new QVTKWidget;
ui->verticalLayout->addWidget(_qvtkWidget);
ui->verticalLayout->update();
_qvtkRenderer = vtkRenderer::New();
_qvtkWidget->GetRenderWindow->AddRenderer(_qvtkRenderer);
_qvtkRenderer->SetBackground(0,0,0);
_qvtkRenderer->Render();
Hope this works for you!