<div dir="ltr">In both openFile() and saveFile()<br><br>filename is out of scope. you shouls be using fileName.toLatin1() instead.<br><br>Jothy<br><br><div class="gmail_quote">On Fri, Aug 17, 2012 at 1:57 PM, Agata Krasoń <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,<div><br></div><div>I have one more question to You a propos de qt:</div><div>I created qui (I send You screen).</div>
<div>I made 2 slots openFile() and saveFile()</div><div><br></div><div>I can&#39;t call well all .</div>
<div><br></div><div>For the moment Could You look at this code ?</div><div>Principally on constructor : I think that it is something wrong with it..</div><div><br></div><div><br></div><div><div>#include &quot;ui_SimpleViewUI.h&quot;</div>

<div>#include &quot;SimpleViewUI.h&quot;</div><div> </div><div>#include &lt;vtkPolyDataMapper.h&gt;</div><div>#include &lt;vtkRenderer.h&gt;</div><div>#include &lt;vtkPolyData.h&gt;</div><div>#include &lt;vtkRenderWindow.h&gt;</div>

<div>#include &lt;vtkSphereSource.h&gt;</div><div>#include &lt;vtkXMLPolyDataReader.h&gt;</div><div>#include &lt;vtkXMLPolyDataWriter.h&gt;</div><div>#include &quot;vtkSmartPointer.h&quot;</div><div><br></div><div>#include &lt;QString&gt;</div>

<div>#include &lt;QFileDialog&gt;</div><div>#include &lt;QMessageBox&gt;</div><div>#include &lt;QFile&gt;</div><div> </div><div>// Constructor</div><div class="im"><div>SimpleView::SimpleView() </div><div>{</div><div>  this-&gt;ui = new Ui_SimpleView;</div>

<div>  this-&gt;ui-&gt;setupUi(this);</div><div><br></div><div><br></div><div><br></div></div><div class="im"><div><font color="#cc0000">   // VTK Renderer</font></div><div><font color="#cc0000">  vtkSmartPointer&lt;vtkRenderer&gt; renderer = vtkSmartPointer&lt;vtkRenderer&gt;::New();</font></div>

<div><font color="#cc0000"> </font></div></div><div class="im"><div><font color="#cc0000">  // VTK/Qt wedded</font></div><div><font color="#cc0000">  this-&gt;ui-&gt;qvtkWidget-&gt;GetRenderWindow()-&gt;AddRenderer(renderer);</font></div>
<div>
<font color="#cc0000"><br></font></div></div><div><font color="#cc0000"> // vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();</font></div><div class="im"><div><font color="#cc0000"><br></font></div><div><font color="#cc0000">  vtkPolyData* polydata = vtkPolyData::New();</font></div>

<div><font color="#cc0000">  polydata = reader-&gt;GetOutput();</font></div><div><font color="#cc0000"><br></font></div><div><font color="#cc0000">  vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();</font></div>

<div><font color="#cc0000">  mapper-&gt;SetInput(polydata);</font></div><div><font color="#cc0000">  vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();</font></div><div><font color="#cc0000">  actor-&gt;SetMapper(mapper);</font></div>

</div><div><font color="#cc0000">  renderer-&gt;AddActor(actor);</font></div><div class="im"><div><font color="#cc0000"><br></font></div><div><font color="#cc0000"> </font></div><div><font color="#cc0000">  // Set up action signals and slots</font></div>

<div><font color="#cc0000">  connect(this-&gt;ui-&gt;actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));</font></div><div><font color="#cc0000">  connect(this-&gt;ui-&gt;openButton, SIGNAL(clicked()), this, SLOT(openFile()));</font></div>

<div><font color="#cc0000">  connect(this-&gt;ui-&gt;saveButton, SIGNAL(clicked()), this, SLOT(saveFile()));</font></div><div><font color="#cc0000">  </font></div><div><font color="#cc0000">  setWindowTitle(&quot;Display Model - Mesh - Surface&quot;);</font></div>

<div> </div><div> </div><div>}</div><div> </div></div><div>void SimpleView::slotExit() </div><div>{</div><div>  qApp-&gt;exit();</div><div>}</div><div><br></div><div>void SimpleView::openFile()</div><div>{</div><div><br>
</div><div>
<span style="white-space:pre-wrap">        </span> QString fileName = QFileDialog::getOpenFileName(this, tr(&quot;Open file with model/mesh&quot;), &quot;&quot;, tr(&quot;files (*.vtp);;All Files (*)&quot;));</div><div class="im">

<div><br></div><div><span style="white-space:pre-wrap">        </span> std::string  filename = fileName.toLatin1();</div></div><div><span style="white-space:pre-wrap">        </span> vtkXMLPolyDataReader* reader = vtkXMLPolyDataReader::New();</div>

<div><span style="white-space:pre-wrap">        </span> reader-&gt;SetFileName(filename.c_str());</div><div>         reader-&gt;Update();</div><div><br></div><div><span style="white-space:pre-wrap">        </span></div>
<div> </div><div>}</div><div><br></div><div>void SimpleView::saveFile()</div><div>{</div><div><span style="white-space:pre-wrap">        </span> // std::cout &lt;&lt;&quot; save  file &quot;&lt;&lt;std::endl;</div>
<div><span style="white-space:pre-wrap">        </span> QString fileName = QFileDialog::getSaveFileName(this, tr(&quot;Save File&quot;), &quot; &quot;,tr(&quot;Images/models (*.vtp)&quot;));</div><div class="im"><div><br></div>

<div>     std::string filename = fileName.toLatin1();</div></div><div><span style="white-space:pre-wrap">        </span> vtkXMLPolyDataWriter* writer = vtkXMLPolyDataWriter::New();</div><div>     writer-&gt;SetInputConnection(reader-&gt;GetOutputPort());</div>

<div>     writer-&gt;SetFileName(filename.c_str());</div><div>     writer-&gt;Write();</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>    </div>

<div><br></div><div>}</div><div><br></div><div><br></div><div>SimpleView::~SimpleView(){}<span style="white-space:pre-wrap">        </span></div><div><br></div><div>I would appreciate for any help please.</div>
</div><div><br></div><div><br></div><div>agata</div><div><br><div class="gmail_quote">2012/8/17 Jothybasu Selvaraj <span dir="ltr">&lt;<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">And post your code, it seems to that you are not seeting the file name properly.<br><br><br><br><div class="gmail_quote">

<div><div>On Fri, Aug 17, 2012 at 12:36 PM, agatte <span dir="ltr">&lt;<a href="mailto:agatakrason@gmail.com" target="_blank">agatakrason@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hi ;)<br>
<br>
I launch program. I can&#39;t open&amp;load a vtp file and save.<br>
I received error info :<br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 204<br>
vtkXMLPolyDataReader (07809840): File name not specified<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (0780AFF0): Algorithm<br>
vtkXMLPolyDataReader(07809840) returned failure for request: vtkInformation<br>
(0783C218)<br>
  Debug: Off<br>
  Modified Time: 1556<div class="im"><br>
  Reference Count: 1<br>
  Registered Events: (none)<br>
  Request: REQUEST_INFORMATION<br></div>
  FORWARD_DIRECTION: 0<br>
  ALGORITHM_AFTER_FORWARD: 1<br>
  FROM_OUTPUT_PORT: 0<br>
<br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 204<br>
vtkXMLPolyDataReader (07809840): File name not specified<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (0780AFF0): Algorithm<br>
vtkXMLPolyDataReader(07809840) returned failure for request: vtkInformation<br>
(0782D208)<br>
  Debug: Off<br>
  Modified Time: 1687<div class="im"><br>
  Reference Count: 1<br>
  Registered Events: (none)<br>
  Request: REQUEST_DATA<br></div>
  FORWARD_DIRECTION: 0<br>
  ALGORITHM_AFTER_FORWARD: 1<br>
  FROM_OUTPUT_PORT: 0<div class="im"><br>
<br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\IO\vtkXMLReader.cxx, line 219<br></div>
vtkXMLPolyDataReader (0782C818): Error opening file XM€<div class="im"><br>
<br>
ERROR: In C:\VTK\VTK-5.8\sources\Filtering\vtkExecutive.cxx, line 756<br></div>
vtkStreamingDemandDrivenPipeline (078302F0): Algorithm<br>
vtkXMLPolyDataReader(0782C818) returned failure for request: vtkInformation<br>
(0C67E420)<br>
  Debug: Off<br>
  Modified Time: 1976<div class="im"><br>
  Reference Count: 1<br>
  Registered Events: (none)<br>
  Request: REQUEST_INFORMATION<br></div>
  FORWARD_DIRECTION: 0<br>
  ALGORITHM_AFTER_FORWARD: 1<br>
<br>
<br>
<br>
<br>
<br>
<br><span class="HOEnZb"><font color="#888888">
<br></font></span></div></div><span class="HOEnZb"><font color="#888888">
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715378.html" target="_blank">http://vtk.1045678.n5.nabble.com/Example-VTK-with-Qt-Load-and-Save-VTP-file-tp5715374p5715378.html</a></font></span><div class="im">
<br>


Sent from the VTK - Users mailing list archive at Nabble.com.</div><div><br><div class="im">
<div><div>_______________________________________________<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>
</div></div></div></div></blockquote></div><span><font color="#888888"><br><br clear="all"><br><div class="im">-- <br><div dir="ltr">Jothybasu Selvaraj<br>PhD Student<br>University of Liverpool<br>UK<br></div><br>
</div></font></span></div>
</blockquote></div><br></div>
</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>