Important: Please read the Qt Code of Conduct -

QTextEdit : how to force LeftToRight text direction for RightToLeft languages

  • I've tried, this:

    QTextOption topt = textedit->document()->defaultTextOption();

    and this:

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

    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