In Qt's implementation arabic notation is shown in right-to-left direction, thus any strings that contain arabic notations will be right-aligned.
But what my application wants to do is showing all texts in left-to-right direction, whether it contains arabic notations or not. And all texts are left-aligned.
An example is shown below:
This is what I want to implement
This is how
QLineEdit
displays texts containing arabic notations in its default wayThis is how
QLabel
does it
EDIT:
Paste the test string here. ە抠门哥ە(
EDIT:
Providing an alternate solution.
Finally I can achieve my goal roughly by using QTextEdit
which has a QTextDocument
. The following code snippet shows how I did it. But I have no idea how Qt deals with text direction from a global perspective, so I can't achieve my goal with QLabel
etc... It would be great if someone can give some detailed information about Qt's text engine.
QTextDocument *doc = ui->textEdit->document();
QTextOption textOption = doc->defaultTextOption();
textOption.setTextDirection(Qt::LeftToRight);
doc->setDefaultTextOption(textOption);
ui->textEdit->setDocument(doc);