<?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[Trigger method when number of lines of QTextBlock changed in QPlainTextEdit]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a <strong>QPlainTextEdit</strong> widget configured with</p>
<pre><code>setLineWrapMode(QPlainTextEdit.WidgetWidth)  # allows QTextBlock inside the QPlainTextEdit to be splitted into multiple lines
</code></pre>
<p dir="auto">which is composed of multiple <strong>QTextBlock</strong></p>
<p dir="auto">Then based on the length of the block and the widget size, the block will be splitted into multiple lines.<br />
I can recover the number of lines inside a block with method</p>
<pre><code>lineCount()
</code></pre>
<p dir="auto"><strong>Question:</strong><br />
Is it possible to get a signal or build a signal allowing to trigger a method each time the number of lines inside a block of the QPlainTextEdit widget change ?</p>
<p dir="auto"><strong>My goal:</strong><br />
On the left of my QPlainTextEdit, I have line numbers and I would like to adapt their size (height) so that the line number corresponding to a block match the size of the block (= line height * number of lines inside the block).<br />
To achieve that, I need to trigger this computation each time the height of the block change (when its number of lines change)</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/topic/141549/trigger-method-when-number-of-lines-of-qtextblock-changed-in-qplaintextedit</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 19:15:52 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141549.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Dec 2022 12:00:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trigger method when number of lines of QTextBlock changed in QPlainTextEdit on Fri, 16 Dec 2022 12:25:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/regex">@<bdi>Regex</bdi></a><br />
While you wait for a better answer.</p>
<p dir="auto">I don't think you will get a signal from Qt for the increased number of visible lines.  You will get one for any change, and I would guess you then have to do the work to calculate if that has changed the number of lines.</p>
<p dir="auto">Meanwhile you might Google for <code>qplaintextedit line numbers</code>.  There are a few links which you might want to read through, e.g. <a href="https://stackoverflow.com/questions/2443358/how-to-add-lines-numbers-to-qtextedit" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/2443358/how-to-add-lines-numbers-to-qtextedit</a> or <a href="https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/" target="_blank" rel="noopener noreferrer nofollow ugc">https://nachtimwald.com/2009/08/19/better-qplaintextedit-with-line-numbers/</a></p>
]]></description><link>https://forum.qt.io/post/740550</link><guid isPermaLink="true">https://forum.qt.io/post/740550</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 16 Dec 2022 12:25:50 GMT</pubDate></item></channel></rss>