[Qt-interest] View UTF-8 text by QGraphicsTextItem

Bart van Deenen bart.vandeenen at gmail.com
Sun Mar 7 15:55:46 CET 2010


M. Bashir Al-Noimi wrote:

> Hi All,
> 
> When I tried to add QGraphicsTextItem item in 
QGraphicsScene object I
> got illegal characters (as shown in the following pix) 
although I used
> QString::fromUtf8 function !!!
> 
> *How I can view utf8 text in QGraphicsView?*
> 
> 
> snippet---
> 
>      graphic_itemText =new  
QGraphicsTextItem(QString::fromUtf8("نص
>      عربي")); scene->addItem(graphic_itemText);
>      graphic_itemText->setFont(QFont("Tahoma", 15));
>      graphic_itemText->setPos(sceneWidth-
pix_factory.width()-100, 15);

Hi

since you're putting utf-8 encoded characters into your cpp 
source file, I'd say you can just do
graphic_itemText =new QGraphicsTextItem("نص عربي");

Bart




More information about the Qt-interest-old mailing list