Important: Please read the Qt Code of Conduct -

[SOLVED] QLineEdit and QPlainTextEdit Right to left mode not working

  • Hi i am expecting that when i do
    @QApplication::setLayoutDirection(Qt::RightToLeft); @
    @ QLineEdit * m_pEditBox = new QLineEdit();

    in the QLineEdit or QPlainTextEdit the cursor should start at the right hand side of the edit and text should be entered toward the left. Instead it stays the same as left to right. Is this the standard behaviour of QLineEdit or is there something else that i should do?

  • According to the documentation for setLayoutDirection, "this method no longer affects text layout direction since Qt 4.7." The new way of doing it is to just make sure you have the current language set correctly, and then Qt will know which languages to display in right-to-left mode (in theory!).

  • @SimeonL
    Have you tested this? I'm interessed in because I need this function in the next project!

  • We have since tested it and as Chris H has suggested it depends on the direction of the characters. It seems to go through the string that is set and when it finds the first char that is strictly right to left or left to right it sets the direction based on that.

Log in to reply