[vtkusers] Example VTK with Qt

Jothybasu Selvaraj jothybasu at gmail.com
Fri Aug 17 08:06:41 EDT 2012


use

reader->SetFileName(filename*.toLatin1()*);

Jothy

On Fri, Aug 17, 2012 at 1:00 PM, agatte <agatakrason at gmail.com> wrote:

> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Jothybasu Selvaraj
PhD Student
University of Liverpool
UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120817/f31bddd8/attachment.htm>


More information about the vtkusers mailing list