The problem is caused by applying justification on arabic letters that's meant for latin ones.
Arabic letters cannot have spaces between them, unlike latin letters, and since justifying text in QTextEdit
seems to mess with letter spacing, it cannot be applied to arabic text, because it simply makes it look ugly and unpleasant to read because of the in between letters gaps.
One solution that seems to work partially, is to use the stretch metric of the used font. In my case, a value of 50
made the gaps almost completely disappear, but it's too tight.
QFont f=text->font();
f.setStretch(50);
f.setLetterSpacing(QFont::AbsoluteSpacing,-0.3);
f.setWordSpacing(2);
text->setFont(f);
You can also combine it with a custom letter and word spacing, it depends on your situation and how it affects your text.
You can take a look at the result, the difference is quite noticeable.
Before:

After:

Note:
The proper way to solve this problem is to use an algorithm that inserts kashidas ('ـ') into the arabic text, instead of manipulating font metrics, but this is not available in qt, one has to do that on their own, which is not an easy task.