<?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] Indent multiple lines with TAB in a QPlainTextEdit]]></title><description><![CDATA[<p dir="auto">Hi</p>
<p dir="auto">I am very new to Qt and my plan is to write a little text editor for a better understanding in Qt. But I have a little problem with the indentation and the TAB key.</p>
<p dir="auto">Is there an easy way to indent multiple (selected) lines with the tab key ? At the moment, it replaces the selected lines with a tab - example:</p>
<p dir="auto">Current situation:<br />
@<br />
Line 1<br />
Line 2<br />
Line 3<br />
Line 4<br />
@</p>
<p dir="auto">Planed:</p>
<p dir="auto">@<br />
&lt;Tab&gt;Line 1<br />
&lt;Tab&gt;Line 2<br />
&lt;Tab&gt;Line 3<br />
&lt;Tab&gt;Line 4<br />
@</p>
<p dir="auto">But the default behaviour is this, because the 4 lines are replaced with a tab (because they are selected):</p>
<p dir="auto">@<br />
&lt;Tab&gt;<br />
@</p>
<p dir="auto">Is there a way to override this behaviour or to write an indent/outdent function ?</p>
<p dir="auto">Greets</p>
]]></description><link>https://forum.qt.io/topic/21236/solved-indent-multiple-lines-with-tab-in-a-qplaintextedit</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 11:46:21 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/21236.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Nov 2012 07:29:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] Indent multiple lines with TAB in a QPlainTextEdit on Fri, 09 Nov 2012 12:36:12 GMT]]></title><description><![CDATA[<p dir="auto">Okay, thank you, that's a good starting point</p>
<p dir="auto">-PS: Is there a button to mark the thread as solved ?- Titel</p>
]]></description><link>https://forum.qt.io/post/156468</link><guid isPermaLink="true">https://forum.qt.io/post/156468</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 09 Nov 2012 12:36:12 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] Indent multiple lines with TAB in a QPlainTextEdit on Fri, 09 Nov 2012 08:19:16 GMT]]></title><description><![CDATA[<p dir="auto">Hello Threadcore,<br />
You should subclass QPlainTextEdit and override following method:<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/virtual">@<bdi>virtual</bdi></a> void QPlainTextEdit::keyPressEvent ( QKeyEvent * e )@</p>
<p dir="auto">Catch the tab key as described in <a href="http://doc.qt.digia.com/qt/qwidget.html#keyPressEvent" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.digia.com/qt/qwidget.html#keyPressEvent</a><br />
Then you should iterate through selected lines and prepend tab character ('\t').<br />
You can obtain the selection through a QTextCursor object, which in turn you can obtain by method<br />
@QTextCursor QPlainTextEdit::textCursor () const@</p>
]]></description><link>https://forum.qt.io/post/156436</link><guid isPermaLink="true">https://forum.qt.io/post/156436</guid><dc:creator><![CDATA[videl]]></dc:creator><pubDate>Fri, 09 Nov 2012 08:19:16 GMT</pubDate></item></channel></rss>