<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit]]></title><description><![CDATA[<p dir="auto">html text is aligned only to left or right, but not both in qlabel, qtextbrowser or qtextedit. Did anyone have the same problem before?<br />
I know QWebengineView works with html text for justfied alignment.</p>
<pre><code>#include &lt;QApplication&gt;
#include &lt;QTextEdit&gt;

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    // Create a QTextEdit
    QTextEdit textEdit;
    textEdit.setAlignment( Qt::AlignJustify );

    // Set HTML content with justified text alignment
    QString htmlContent = "&lt;html&gt;&lt;body&gt;"
                          "&lt;p style='text-align:justify;'&gt;This is a sample text with justified alignment.Additional paragraphs can be added as needed."
                          "Additional paragraphs can be added as needed.This is a sample text with justified alignment.&lt;/p&gt;"
                          "&lt;/body&gt;&lt;/html&gt;";
    textEdit.setHtml(htmlContent);

    // Remove the border using a style sheet
    textEdit.setStyleSheet("border: none;");

    // Show the QTextEdit
    textEdit.show();

    return app.exec();
}
</code></pre>
<p dir="auto">Linux 22.04 and Qt 5.15.3</p>
]]></description><link>https://forum.qt.io/topic/152636/html-text-can-not-be-justified-on-both-left-and-right-sides-in-qlabel-qtextbrowser-and-qtextedit</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 23:26:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/152636.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Dec 2023 17:36:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 00:02:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> You can use plain HTML instead of CSS: <code>&lt;p align='justify'&gt;</code>.</p>
]]></description><link>https://forum.qt.io/post/781993</link><guid isPermaLink="true">https://forum.qt.io/post/781993</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 06 Dec 2023 00:02:22 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 14:55:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-kawa">@<bdi>Chris-Kawa</bdi></a> Tested it. Works nicely. Many thanks.</p>
]]></description><link>https://forum.qt.io/post/782047</link><guid isPermaLink="true">https://forum.qt.io/post/782047</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Wed, 06 Dec 2023 14:55:03 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 10:10:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-kawa">@<bdi>Chris-Kawa</bdi></a><br />
I can confirm it works in Qt 5.15.2.</p>
]]></description><link>https://forum.qt.io/post/782031</link><guid isPermaLink="true">https://forum.qt.io/post/782031</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Wed, 06 Dec 2023 10:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 08:41:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> I don't have Qt 5 at hand, but it works in 6.6.</p>
]]></description><link>https://forum.qt.io/post/782027</link><guid isPermaLink="true">https://forum.qt.io/post/782027</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 06 Dec 2023 08:41:42 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 00:47:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-kawa">@<bdi>Chris-Kawa</bdi></a> Thanks for your reply, Chris. I tried it and only one line is displayed. I will look into this later.</p>
]]></description><link>https://forum.qt.io/post/781994</link><guid isPermaLink="true">https://forum.qt.io/post/781994</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Wed, 06 Dec 2023 00:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Wed, 06 Dec 2023 00:02:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a> You can use plain HTML instead of CSS: <code>&lt;p align='justify'&gt;</code>.</p>
]]></description><link>https://forum.qt.io/post/781993</link><guid isPermaLink="true">https://forum.qt.io/post/781993</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Wed, 06 Dec 2023 00:02:22 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Tue, 05 Dec 2023 19:47:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a> It is not a HTML thing. QWebEngineView justifies the html text well. I guess these widgets do not support enough html features. When I use QWebEngineView, it creates a spacing at its top and bottom and I can not reduce it.</p>
]]></description><link>https://forum.qt.io/post/781971</link><guid isPermaLink="true">https://forum.qt.io/post/781971</guid><dc:creator><![CDATA[JoeCFD]]></dc:creator><pubDate>Tue, 05 Dec 2023 19:47:11 GMT</pubDate></item><item><title><![CDATA[Reply to html text can not be justified on both(left and right) sides in qlabel, qtextbrowser and qtextedit on Tue, 05 Dec 2023 19:19:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joecfd">@<bdi>JoeCFD</bdi></a></p>
<p dir="auto">What happens if you</p>
<pre><code>widget-&gt;setAlignment(Qt::AlignJustify)
</code></pre>
<p dir="auto"><strong>afterwards</strong> (after setting the text/html)?<br />
Does it work at all? If so, then it must be something with the HTML</p>
]]></description><link>https://forum.qt.io/post/781970</link><guid isPermaLink="true">https://forum.qt.io/post/781970</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Tue, 05 Dec 2023 19:19:50 GMT</pubDate></item></channel></rss>