How to align text in QTextEdit
Solved
General and Desktop
-
Hi,
I want to align text present in QTextEdit.
I tried some options present in net like " text-align:center" but they didn't work.Could you please help me on this...
Regards,
Anuj -
Hi
You can always just right click a TextEdit in Designer and use its Edit HTML editor.
It allows you to do basic things and get the html.<html><head/><body><p align="center"><span style=" font-size:8.25pt;">CENTER</span></p></body></html>
-
You can use setAlignment() method. Here's an example:
QTextEdit te; te.append("This paragraph is left aligned"); te.setAlignment(Qt::AlignLeft); te.append("This paragraph is right aligned"); te.setAlignment(Qt::AlignRight);
or you can use html:
QTextEdit te; te.setHtml("<p align=\"left\">This paragraph is left aligned" "<p align=\"right\">This paragraph is right aligned");
or CSS:
QTextEdit te; te.setHtml("<p style=\"text-align: left\">This paragraph is left aligned" "<p style=\"text-align: right\">This paragraph is right aligned");
-
@Chris-Kawa Thanks..it's working