Qt - How to change the direction of placeholder in a QLineEdit?

I am using Qt 4.7.4 and my application language in RTL. I have set the application layout to RightToLeft. So everything is now right to left except placeholders in QLineEdit.

I tried setAlignment method but it changes the text and placeholder direction in reverse. Then I tried setStylesheet but it does not work for

direction:rtl;
text-align:right;
unicode-bidi:embed;

I think it is a bug, Is there any fix?

Answers


The changelog for version 4.7 reads as follows:

QWidget::setLayoutDirection no longer affects the text layout direction (Qt::LeftToRight or Qt::RightToLeft) of QTextEdit, QLineEdit and widgets based on them. The default text layout direction (Qt::LayoutDirectionAuto) is now detected from keyboard layout and language of the text (conforms to Unicode standards). To programmatically force the text direction of a QTextEdit, you can change the defaultTextOption of the QTextDocument associated with that widget with a new QTextOption of different textDirection property. For QLineEdit, the only way so far is sending a Qt::Key_Direction_L/R keyboard event to that widget.

Hope that helps.


Need Your Help

Bash: Unable to enter into if even the condition is true

mysql wordpress bash backup

I am building a script which will backup a WordPress database.

Winforms Checkbox Focus Problem if no Text is Applied on Checkbox

winforms checkbox focus

I have a multiple checkboxes on a Winforms without having the Text Property of all checkboxes,