[Qt-interest] RTL text input problem

Diego Iastrubni diegoiast at gmail.com
Fri Feb 12 15:40:46 CET 2010


The only problem is that you did not define the paragraph direction to RTL -
the widget is RTL, but the content direction is LRT.

Read this for more information, but in short:
QTextEdit *e3 = new QTextEdit;
QTextCursor tc = e3->textCursor();
QTextBlockFormat tbf = tc.blockFormat();

tbf.setLayoutDirection( Qt::RightToLeft );
tc.setBlockFormat(tbf);
tc.insertText( QLatin1String("3) Correct direction on QTextEdit, wanted
RTL!") );
e3->setTextCursor(tc);

On Fri, Feb 12, 2010 at 11:21 AM, <Oliver.Knoll at comit.ch> wrote:

> rm rm wrote on Friday, February 12, 2010 8:50 AM:
>
> > ...when I type a word in the widget ( arabic) all the
> > things are right but when I press the Space key the cursor goes at
> > the begining of the line. and then after pressing another key the
> > cursor jumps to the end of line and all the things are right untile
> > another space character .
>
> I can reproduce this behaviour with the example
> %QTDIR%\examples\mainwindows\mdi\ (
> http://qt.nokia.com/doc/4.6/mainwindows-mdi.html), see attached
> screenshot. In the "File" menu the layout direction can be set.
>
> The spaces are inserted at the proper places (between the words), but after
> each time the "space" (key) is hit, the cursor jumps to the very left (and
> changes its look: the very small "arrow" thing points to the left instead of
> to the right).
>
> Pressing "Space" multiple times initially inserts the whitespace also to
> the left, but as soon as the first "non-space" character is entered the
> space and the non-space character are properly positioned again on the
> right.
>
> But maybe I am also misunderstanding the concept of the layout direction
> "Right to left": When I enter text such as "This text is right to left",
> should it not be displayed as:
>
>  "tfel ot thgir si txet sihT"
>
> (That is, in "reverse" order, or as "read from right to left")
> ?
>
> It appears to me that I still write "left to right", with the only
> difference that the text is right-aligned. Or does one have to set some
> other settings (besides the
> http://qt.nokia.com/doc/4.6/qt.html#LayoutDirection-enum) in the Qt API as
> to support properly "right-to-left" languages?
>
>
> As seen on Windows XP SP3, Qt 4.6.1, compiled from source (VS 2005).
>
>
> Cheers, Oliver
> --
> Oliver Knoll
> Dipl. Informatik-Ing. ETH
> COMIT AG - ++41 79 520 95 22
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100212/43a67718/attachment.html 


More information about the Qt-interest-old mailing list