<?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[[~Solved] Set Alignment in QGraphicsTextItem?]]></title><description><![CDATA[<p dir="auto">How do I properly align a multi-line text in a QGraphicsTextItem?<br />
The text seems to be always left-aligned, despite specifying</p>
<p dir="auto">@    QTextOption option = pTextItem-&gt;document()-&gt;defaultTextOption();<br />
option.setAlignment(Qt::AlignCenter);<br />
pTextItem-&gt;document()-&gt;setDefaultTextOption(option);@</p>
<p dir="auto">I have also tried assigning an alignment to all text blocks - no effect.</p>
<p dir="auto">Ideas?</p>
<p dir="auto">Edit: I only use plain text. I have found "this Bug":<a href="https://bugreports.qt-project.org/browse/QTBUG-312" target="_blank" rel="noopener noreferrer nofollow ugc">https://bugreports.qt-project.org/browse/QTBUG-312</a> regarding html text.</p>
]]></description><link>https://forum.qt.io/topic/33981/solved-set-alignment-in-qgraphicstextitem</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 08:34:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/33981.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Nov 2013 17:53:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [~Solved] Set Alignment in QGraphicsTextItem? on Thu, 07 Nov 2013 08:07:26 GMT]]></title><description><![CDATA[<p dir="auto">It seems, the alignment only works if the document's textWidth is set.</p>
<p dir="auto">I expected it to work without the text width, based on the length of the longest text line.</p>
]]></description><link>https://forum.qt.io/post/203142</link><guid isPermaLink="true">https://forum.qt.io/post/203142</guid><dc:creator><![CDATA[Asperamanca]]></dc:creator><pubDate>Thu, 07 Nov 2013 08:07:26 GMT</pubDate></item><item><title><![CDATA[Reply to [~Solved] Set Alignment in QGraphicsTextItem? on Thu, 07 Nov 2013 07:59:14 GMT]]></title><description><![CDATA[<p dir="auto">I would also do it in the constructor. As a workaround, did you try to resize the item as suggested in the bug report ?</p>
]]></description><link>https://forum.qt.io/post/203140</link><guid isPermaLink="true">https://forum.qt.io/post/203140</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 07 Nov 2013 07:59:14 GMT</pubDate></item><item><title><![CDATA[Reply to [~Solved] Set Alignment in QGraphicsTextItem? on Thu, 07 Nov 2013 07:21:49 GMT]]></title><description><![CDATA[<p dir="auto">I've tried setting the default text alignment</p>
<ul>
<li>when the object is created (when text is still empty)</li>
<li>on every contentsChanged() signal</li>
</ul>
<p dir="auto">I've tried setting the text alignment for all text blocks</p>
<ul>
<li>whenver the block count changes</li>
</ul>
<p dir="auto">Any other places I should try?</p>
]]></description><link>https://forum.qt.io/post/203129</link><guid isPermaLink="true">https://forum.qt.io/post/203129</guid><dc:creator><![CDATA[Asperamanca]]></dc:creator><pubDate>Thu, 07 Nov 2013 07:21:49 GMT</pubDate></item><item><title><![CDATA[Reply to [~Solved] Set Alignment in QGraphicsTextItem? on Wed, 06 Nov 2013 22:27:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Just a question, do you set the option before or after setting the text ?</p>
]]></description><link>https://forum.qt.io/post/203099</link><guid isPermaLink="true">https://forum.qt.io/post/203099</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 06 Nov 2013 22:27:37 GMT</pubDate></item></channel></rss>