<div dir="ltr">use<br><br> reader->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"><<a href="mailto:agatakrason@gmail.com" target="_blank">agatakrason@gmail.com</a>></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 = "file.vtp";<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->ui = new Ui_SimpleView;<br>
this->ui->setupUi(this);<br>
<br>
<br>
<br>
<br>
//const char* filename = "outputMeshXML.vtp";<br>
<br>
// Here !!!!!<br>
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File..."),<br>
QString(), tr("VTP-Files<br>
(*.vtp);;All Files (*)"));<br>
<br>
const char* filename = fileName.toStdString().c_str();<br>
vtkSmartPointer<vtkXMLPolyDataReader> reader =<br>
vtkSmartPointer<vtkXMLPolyDataReader>::New();<br>
reader->SetFileName(filename);<br>
reader->Update();<br>
<br>
<br>
vtkPolyData* polydata = vtkPolyData::New();<br>
polydata = reader->GetOutput();<br>
<br>
vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper->SetInput(polydata);<br>
vtkSmartPointer<vtkActor> actor =<br>
vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(mapper);<br>
<br>
// VTK Renderer<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
renderer->AddActor(actor);<br>
<br>
// VTK/Qt wedded<br>
this->ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);<br>
<br>
// Set up action signals and slots<br>
connect(this->ui->actionExit, SIGNAL(triggered()), this,<br>
SLOT(slotExit()));<br>
connect(this->ui->openButton, SIGNAL(clicked()), this, SLOT(openFile()));<br>
connect(this->ui->saveButton, SIGNAL(clicked()), this, SLOT(saveFile()));<br>
<br>
setWindowTitle("Display Model - Mesh - Surface");<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>