linux 而非 运行 上的 QT、VTK 项目

QT, VTK project on linux not running

我正在尝试使用 Qt 启动一个 ITK/VTQ 项目。该项目在 Windows 10 上运行,但不在 Ubuntu.

上运行

我在启动项目时遇到以下错误:

X Error: BadColor (invalid Colormap parameter) 12
  Major opcode: 1 (X_CreateWindow)
  Resource id:  0x4a00001
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 3 (X_GetWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 7 (X_ReparentWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 10 (X_UnmapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 12 (X_ConfigureWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 8 (X_MapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 8 (X_MapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 3 (X_GetWindowAttributes)
  Resource id:  0x480001a
Erreur de segmentation (core dumped)

这是我的代码:

void ImageViewerWidget::InitRender()
{

/*** INITIALIZATION ***/

// init the actor
m_texturedQuad = vtkSmartPointer<vtkActor>::New();
_openGLproperty = static_cast<vtkOpenGLProperty*>(m_texturedQuad->GetProperty());

// init the quad
_quadPolyData = vtkSmartPointer<vtkPolyData>::New();


// create the texture object
_textureCoordinates = vtkSmartPointer<vtkFloatArray>::New();
_textureCoordinates->SetNumberOfComponents(3);
_textureCoordinates->SetName("TextureCoordinates");

float tuple[3] = {0.0, 0.0, 0.0};
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 1.0; tuple[1] = 0.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 1.0; tuple[1] = 1.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 0.0; tuple[1] = 1.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);


// create the itk/vtk converter
m_itkToVtkConverter = itk::ImageToVTKImageFilter<itk::Image<float, 3> >::New();


/*** Init the Renderer ***/
m_imageRenderer = vtkSmartPointer<vtkRenderer>::New();
m_imageRenderer->SetBackground(1,1,1); // Background color white
m_imageRenderer->ResetCamera();


/*** Init the Render Window ***/
m_imageRenderWindow = vtkSmartPointer<vtkRenderWindow>::New();
m_imageRenderWindow->AddRenderer(m_imageRenderer);


/*** Init the Shader ***/
SetActiveShader("BasicShader");


/*** Set Render Window to viewer ***/
// FIXME: the software crashes here on GNU/Linux
viewer->SetRenderWindow(m_imageRenderWindow);

}

我发现问题出在这里:

viewer->SetRenderWindow(m_imageRenderWindow);

如何更正此错误消息?

问题出在哪里?

你的大部分代码(_textureCoordinates 和上面的东西)没有连接到其余部分。你在这里展示的不是一个可运行的例子,但看起来你没有正确设置 VTK(与 VTK hello world 比较)。

您是否尝试过查看一些 examples on VTK wiki? Also, why don't you start with a working VTK/QT example 并逐渐扩展它?