So I started writing some small tests (yes David, I do small scale tests!). In this test I am doing the exact opposite: I am forcing an RTL paragraph on an LTR interface.
QTextEdit *e1 = new QTextEdit;This seems to work fine. However, lokalize creates a QTextCursor and inserts text to that cursor. Ok, second test:
o = e1->document()->defaultTextOption();
e1->setText( QLatin1String("1) Currect direction on QTextEdit, wanted RTL!") );
QTextEdit *e2 = new QTextEdit;This does not work. The text is still LTR, even tough I modified the text char format of this text cursor. I sent a bug to Nokia with this mini-application, and it's marked there as N229677.
QTextCursor tc = e2->textCursor();
QTextCharFormat tcf = tc.blockCharFormat();
tcf.setLayoutDirection( Qt::RightToLeft );
tc.insertText( QLatin1String("2) Wrong direction on QTextEdit, wanted RTL!"), tcf );
I talked with a fellow hacker here, and he sent me this piece of code (which does work), third test:
QTextEdit *e3 = new QTextEdit;Now, I don't really understand why the second test does not work. IMHO, the higher level API used in the second test should work, but I assume that using this low level (which is used in the third test) is fine as well... I will commit this to lokalize as soon as I test on a live lokalize, but it's just crashing on startup since 3 days ago (yes, I am using runk). Is this a known issue?
QTextCursor tc = e3->textCursor();
QTextBlockFormat tbf = tc.blockFormat();
tbf.setLayoutDirection( Qt::RightToLeft );
tc.insertText( QLatin1String("3) Correct direction on QTextEdit, wanted RTL!") );