[vtkusers] Show Chinese Character on qvtkwidget

Simon ESNEAULT simon.esneault at gmail.com
Tue Apr 28 03:34:52 EDT 2015


Hi Lee,

I think this is error shows up because you are converting the string to
local 8 bit when calling the function .toStdString() *
The string must be encoded in Utf8 ** to be rendered properly in VTK.

Try to replace the lines :
----------------------------------------------
std::string str = temp.toStdString();
const char* ch = str.c_str();
m_textActor->SetInput(ch);
----------------------------------------------
by
----------------------------------------------
m_textActor->SetInput( temp.toUtf8().constData() );
----------------------------------------------
Also make sure you save your source file in Utf8

Good luck

Simon

* http://doc.qt.io/qt-4.8/qstring.html#toStdString
** http://en.wikipedia.org/wiki/UTF-8


2015-04-28 3:54 GMT+02:00 lee <lihouxing at yeah.net>:

> Hi,
>      Thanks for your method, but it only works for English character, when
> the string contains Chinese characters, errors come up as follow:
>
> *Generic Warning: In ..\..\..\VTK-6.1.0\Common\Core\vtkUnicodeString.cxx,
> line 183
> vtkUnicodeString::from_utf8(): not a valid UTF-8 string.
>
> Generic Warning: In ..\..\..\VTK-6.1.0\Common\Core\vtkUnicodeString.cxx,
> line 183
> vtkUnicodeString::from_utf8(): not a valid UTF-8 string.
>
> ERROR: In ..\..\..\VTK-6.1.0\Rendering\FreeType\vtkTextActor.cxx, line 803
> vtkScaledTextActor (00D01410): Cannot compute bounding box.
> *
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Show-Chinese-Character-on-qvtkwidget-tp5731627p5731648.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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150428/9efe2eb5/attachment.html>


More information about the vtkusers mailing list