Qt::AlignJustify not working
-
Hello,
I've been having this problem for quite some time and I'd like to solve it once and for all. The following line, in the constructor of a QMainWindow's derived class, doesn't work.
myQTextEdit->setAlignment(Qt::AlignJustify)
The text is never justified whatsoever. Does alignment require anything to work besides setting it? Also, does it matter that the text is set after the alignment?
-
From the documentation: "Sets the alignment of the current paragraph to a".
So yes, if you're usingsetText()
you must set the alignment after you set the text, otherwise you're setting it for whatever was in the text edit before that.
Also note that if you use something likeappend()
to add text you will need to move the cursor to the right position to set the alignment, as thesetAlignment
affects only current paragraph.