[vtkusers] vtkSTLReader and QString

David Cole DLRdave at aol.com
Wed Jan 10 07:13:55 EST 2018


Have you tried

"reader->SetFileName(fileName.toStdString().c_str());"

?



On Wed, Jan 10, 2018 at 4:33 AM, Abdelkhalek Bakkari
<bakkari.abdelkhalek at hotmail.fr> wrote:
> Hi All,
>
>
> I tried to read an STL file using  vtkSTLReader  from a directory as
> follows:
>
>
>
> -------------------------
>
> QString fileName = QFileDialog::getOpenFileName( this, tr("Open File"),
> "C:\\", tr("Mesh (*.stl *.vtk)"));
> if (fileName.isNull()) //user cancelled
> return EXIT_FAILURE;
>
> m_imagePath = fileName;
> //Create an STL reader for reading the file
> vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
> //reader->SetFileName(pathName.c_str());
> reader->SetFileName(fileName.toStdString());
> reader->Update();
> -------------------------
>
>
> But, I've got the following error  :
>
> 'vtkAbstractPolyDataReader::SetFileName' : cannot convert parameter 1 from
> 'std::string' to 'const char *'
>
>
> Could you please propose a solution for this issue?
>
>
>
>
>
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list