QTextEdit : how to force LeftToRight text direction for RightToLeft languages



  • I've tried, this:

    @
    QTextOption topt = textedit->document()->defaultTextOption();
    topt.setTextDirection(Qt::LeftToRight);
    textedit->document()->setDefaultTextOption(topt);
    @

    and this:

    @
    QTextCursor tc = textedit->textCursor();
    QTextBlockFormat tbf = tc.blockFormat();
    tbf.setLayoutDirection( Qt::LeftToRight );
    tc.setBlockFormat(tbf);
    textedit->setTextCursor(tc);
    @

    without success.

    Any ideas would be appreciated. (A QLineEdit would do just as well, but they don't seem to have as many options for controlling text direction.)

    (Why? The textedit will contain a regular expression including Arabic text. Pretty confusing to look at a regex where the text is reversed.)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.