[vtkusers] vtkSTLReader and QString

Marcus D. Hanwell marcus.hanwell at kitware.com
Wed Jan 10 14:13:48 EST 2018


On Wed, Jan 10, 2018 at 9:24 AM, Shawn Waldon <shawn.waldon at kitware.com>
wrote:
>
> 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.
>
> I have been bitten by this a few times, when dealing with files, the STL,
etc you really need to be careful to use toLocal8Bit(), see
https://bugreports.qt.io/browse/QTBUG-39086 for some further background.
You will of course be fine until you encounter non Latin characters, so
toLatin1 or toStdString may work out for common use cases with US-based
users.

Marcus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180110/d53078c4/attachment.html>


More information about the vtkusers mailing list