Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt::AlignJustify not working
Pippin last edited by Pippin
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.
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 using
setText()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 like
append()to add text you will need to move the cursor to the right position to set the alignment, as the
setAlignmentaffects only current paragraph.