[vtkusers] Example VTK with Qt

agatte agatakrason at gmail.com
Fri Aug 17 08:00:55 EDT 2012


Hi,
When specify a file : const char* filename = "file.vtp";
It works well.
But I need to make a qui to choose a file :

I am trying :

SimpleView::SimpleView() 
{
  this->ui = new Ui_SimpleView;
  this->ui->setupUi(this);

   


//const char* filename = "outputMeshXML.vtp";

// Here !!!!!
 QString fileName = QFileDialog::getOpenFileName(this, tr("Open File..."),
                                               QString(), tr("VTP-Files
(*.vtp);;All Files (*)"));
   
  const char* filename = fileName.toStdString().c_str();
  vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
  reader->SetFileName(filename);
  reader->Update();


  vtkPolyData* polydata = vtkPolyData::New();
  polydata = reader->GetOutput();

  vtkSmartPointer<vtkPolyDataMapper> mapper =
      vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInput(polydata);
  vtkSmartPointer<vtkActor> actor = 
      vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
 
  // VTK Renderer
  vtkSmartPointer<vtkRenderer> renderer = 
      vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(actor);
 
  // VTK/Qt wedded
 this->ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
 
  // Set up action signals and slots
  connect(this->ui->actionExit, SIGNAL(triggered()), this,
SLOT(slotExit()));
  connect(this->ui->openButton, SIGNAL(clicked()), this, SLOT(openFile()));
  connect(this->ui->saveButton, SIGNAL(clicked()), this, SLOT(saveFile()));
  
  setWindowTitle("Display Model - Mesh - Surface");
 
 
}



I received always errors  like these :

ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219
vtkXMLPolyDataReader (063F5828): Error opening file L€

ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756
vtkStreamingDemandDrivenPipeline (063F4CB0): Algorithm
vtkXMLPolyDataReader(063F5828) returned failure for request: vtkInformation
(063EC9E8)
  Debug: Off
  Modified Time: 1392
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0



ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219
vtkXMLPolyDataReader (063F5828): Error opening file L€

ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756
vtkStreamingDemandDrivenPipeline (063F4CB0): Algorithm
vtkXMLPolyDataReader(063F5828) returned failure for request: vtkInformation
(064061B8)
  Debug: Off
  Modified Time: 1588
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_DATA
  ALGORITHM_AFTER_FORWARD: 1
  FORWARD_DIRECTION: 0
  FROM_OUTPUT_PORT: 0




--
View this message in context: http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715383.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list