QTextEdit::setAlignment not working.
-
Hello,
the following code,
CardLore.setParent(&MainWidget); CardLore.setReadOnly(true); QString text = "foo foofoofoo foofoo foofoofoofoo foofoo foofoofoofoo foo foofoo foofoofoo foo foofoo"; CardLore.setText(text); CardLore.setAlignment(Qt::AlignJustify); CardLore.resize(447, 98); CardLore.move(401, 501);
where CardLore is a QTextEdit object, fails to justify the text and I don't know why. What am I missing? I've googled my problem but couldn't find a thread about it that was either recent or working.
Thanks in advance for any help.
-
Hi and welcome to devnet,
Calling setAlignment will make the next paragraph use the alignment. So you have to do:
CardLore.setAlignment(Qt::AlignJustify); CardLore.append(text);
Hope it helps
-
Status update:
QPainterObject.drawText(QRect(34, 475, 350, 75), Qt::AlignJustify | Qt::TextWordWrap, someText);
does wrap the text, but seems unabled to justify it as well. So either I'm using Qt::AlignJustify the wrong way, or Qt::AlignJustify doesn't work on Ubuntu.
:(
-
Are you sure it's not the size of your widget that makes it seems like it's not justified ?
-
You were using a QTextEdit and now you are using a painter. What is your current code ?