PDA

View Full Version : QTextEdit Alignment won't stick



jrideout
24th December 2006, 12:42
How do I get QTextEdit to always be aligned the way I want? I can change it just fine with this:


textEdit->setAlignment(Qt::AlignJustify);

I can call this before text is entered into the text edit and it will remain aligned as long as the user edits the text, but if the user pastes texts with multiple blocks or I programmaticaly set the text, the formating is lost. I understand that is how the code snip it above works, but is there a better way, that would make it stick> Otherwise, I'll just have catch contentsChanged signals and reapply the formating each time.

e8johan
7th January 2007, 09:35
Could it be that the pasted text is right-aligned and that the QTextEdit accepts rich text/html - i.e. text that carries alignment data with it.

jrideout
7th January 2007, 17:26
No, I've set it so that: textEdit->setAcceptRichText(false);

Djony
10th January 2007, 15:54
I have similar problem. I use this control and also set alignment to (Qt::AlignJustify) but when i set text in it (which I read from some file), it appears at the center of control. I use setPlaintText() method to put text in this control. I've tried (Qt::AlignLeft|Qt::AlignTop) but the text is still in center, oddly broke. I want it broken in way that there is no need for horizontal slider, just vertical needs to be shown (if there is need for that at all, that is). Does anybody know what I need to set?