<div dir="ltr">use<br><br> reader-&gt;SetFileName(filename<b><span style="color:rgb(255,0,0)">.toLatin1()</span></b>);<br><br>Jothy<br><br><div class="gmail_quote">On Fri, Aug 17, 2012 at 1:00 PM, agatte <span dir="ltr">&lt;<a href="mailto:agatakrason@gmail.com" target="_blank">agatakrason@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
When specify a file : const char* filename = &quot;file.vtp&quot;;<br>
It works well.<br>
But I need to make a qui to choose a file :<br>
<br>
I am trying :<br>
<br>
SimpleView::SimpleView()<br>
{<br>
  this-&gt;ui = new Ui_SimpleView;<br>
  this-&gt;ui-&gt;setupUi(this);<br>
<br>
<br>
<br>
<br>
//const char* filename = &quot;outputMeshXML.vtp&quot;;<br>
<br>
// Here !!!!!<br>
 QString fileName = QFileDialog::getOpenFileName(this, tr(&quot;Open File...&quot;),<br>
                                               QString(), tr(&quot;VTP-Files<br>
(*.vtp);;All Files (*)&quot;));<br>
<br>
  const char* filename = fileName.toStdString().c_str();<br>
  vtkSmartPointer&lt;vtkXMLPolyDataReader&gt; reader =<br>
vtkSmartPointer&lt;vtkXMLPolyDataReader&gt;::New();<br>
  reader-&gt;SetFileName(filename);<br>
  reader-&gt;Update();<br>
<br>
<br>
  vtkPolyData* polydata = vtkPolyData::New();<br>
  polydata = reader-&gt;GetOutput();<br>
<br>
  vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper =<br>
      vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();<br>
  mapper-&gt;SetInput(polydata);<br>
  vtkSmartPointer&lt;vtkActor&gt; actor =<br>
      vtkSmartPointer&lt;vtkActor&gt;::New();<br>
  actor-&gt;SetMapper(mapper);<br>
<br>
  // VTK Renderer<br>
  vtkSmartPointer&lt;vtkRenderer&gt; renderer =<br>
      vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
  renderer-&gt;AddActor(actor);<br>
<br>
  // VTK/Qt wedded<br>
 this-&gt;ui-&gt;qvtkWidget-&gt;GetRenderWindow()-&gt;AddRenderer(renderer);<br>
<br>
  // Set up action signals and slots<br>
  connect(this-&gt;ui-&gt;actionExit, SIGNAL(triggered()), this,<br>
SLOT(slotExit()));<br>
  connect(this-&gt;ui-&gt;openButton, SIGNAL(clicked()), this, SLOT(openFile()));<br>
  connect(this-&gt;ui-&gt;saveButton, SIGNAL(clicked()), this, SLOT(saveFile()));<br>
<br>
  setWindowTitle(&quot;Display Model - Mesh - Surface&quot;);<br>
<br>
<br>
}<br>
<br>
<br>
<br>
I received always errors  like these :<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219<br>
vtkXMLPolyDataReader (063F5828): Error opening file L€<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br>
vtkStreamingDemandDrivenPipeline (063F4CB0): Algorithm<br>
vtkXMLPolyDataReader(063F5828) returned failure for request: vtkInformation<br>
(063EC9E8)<br>
  Debug: Off<br>
  Modified Time: 1392<br>
  Reference Count: 1<br>
  Registered Events: (none)<br>
  Request: REQUEST_INFORMATION<br>
  ALGORITHM_AFTER_FORWARD: 1<br>
  FORWARD_DIRECTION: 0<br>
<br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219<br>
vtkXMLPolyDataReader (063F5828): Error opening file L€<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br>
vtkStreamingDemandDrivenPipeline (063F4CB0): Algorithm<br>
vtkXMLPolyDataReader(063F5828) returned failure for request: vtkInformation<br>
(064061B8)<br>
  Debug: Off<br>
  Modified Time: 1588<br>
  Reference Count: 1<br>
  Registered Events: (none)<br>
  Request: REQUEST_DATA<br>
  ALGORITHM_AFTER_FORWARD: 1<br>
  FORWARD_DIRECTION: 0<br>
  FROM_OUTPUT_PORT: 0<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715383.html" target="_blank">http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715383.html</a><br>

Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothybasu Selvaraj<br>PhD Student<br>University of Liverpool<br>UK<br></div><br>
</div>