[vtkusers] vtkSTLReader and QString
Shawn Waldon
shawn.waldon at kitware.com
Wed Jan 10 09:24:38 EST 2018
On Wed, Jan 10, 2018 at 7:13 AM, David Cole via vtkusers <vtkusers at vtk.org>
wrote:
> Have you tried
>
> "reader->SetFileName(fileName.toStdString().c_str());"
>
> ?
>
> If your filename may have international characters in it, you will want
filename.toLocal8Bit().data() instead. But filename.toStdString().c_str()
will work fine with only ASCII in the filename.
HTH,
Shawn
>
>
> 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
> >
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180110/f4f91f49/attachment.html>
More information about the vtkusers
mailing list