<?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[QTextEdit goes underneath android keyboard when editing]]></title><description><![CDATA[<p dir="auto">I'm trying to make a simplistic text editor (or notes-app clone), for desktop and android. As a minimum-reproducible-example, I have a central widget, with a <code>QVBoxLayout</code>, that contains a <code>QTextEdit</code>.</p>
<p dir="auto">On mobile (I've only tested my android phone), the QTextEdit initially resizes to the remaining available space when the android keyboard is visible, bringing in a scrollbar if necessary for longer texts - which is intended behavior.</p>
<p dir="auto">But when editing, if I insert a new line or move the cursor up or down by a line, the QTextEdit "grows" back to its fullscreen size, and renders half of its text and UI under the keyboard.</p>
<p dir="auto">As another measure, I tried adding a second widget to the QVBoxLayout. Sure enough, it is visible above the keyboard initially when text is being entered, but then disappears under the keyboard when I press enter or move the cursor.</p>
<p dir="auto">Sometimes, I can bring it back to its correct position/layout/size if I close and reopen the keyboard, but that isn't consistent either.</p>
<p dir="auto">How do I make the QTextEdit (and any widget in general) not resize or grow when the android on-screen keyboard is still active?</p>
<h5>Minimal example:</h5>
<p dir="auto">widget.h</p>
<pre><code class="language-c++">#ifndef WIDGET_H
#define WIDGET_H

#include &lt;QWidget&gt;
#include &lt;QTextEdit&gt;
#include &lt;QLayout&gt;

class Widget : public QWidget {
    Q_OBJECT
    QTextEdit* child;
    QLayout* layout;

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
};
#endif // WIDGET_H

</code></pre>
<p dir="auto">widget.cpp</p>
<pre><code class="language-c++">#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    child = new QTextEdit();
    layout = new QVBoxLayout();
    layout-&gt;addWidget(child);
    setLayout(layout);
}

Widget::~Widget() {
    delete layout;
    delete child;
}
</code></pre>
<p dir="auto">main.cpp</p>
<pre><code class="language-c++">#include "widget.h"

#include &lt;QApplication&gt;

int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}
</code></pre>
<p dir="auto">To trigger: Build for android, and then type in 30 lines or so (can be blank), and try to navigate to the bottom or last line - then try moving the cursor one line above, and then back down - the last line (and its text) disappears under the keyboard.</p>
]]></description><link>https://forum.qt.io/topic/164074/qtextedit-goes-underneath-android-keyboard-when-editing</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 14:23:43 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/164074.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Jan 2026 13:42:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTextEdit goes underneath android keyboard when editing on Tue, 13 Jan 2026 16:55:12 GMT]]></title><description><![CDATA[<p dir="auto">I've found a workaround - since the QTextEdit initially is the correct size when I open the keyboard, I can call <code>setMaximumHeight(this-&gt;size().height())</code>, which prevents it from growing vertically on these other events. In other words, for a <code>QTextEdit* editor</code>, you would:</p>
<pre><code class="language-c++">QTextEdit* editor = /* anything here, or if you're using this inside a QTextEdit subclass, use "this" instead... */;

QApplication* app = (QApplication*) (QApplication::instance());
QObject::connect(app-&gt;inputMethod(), &amp;QInputMethod::keyboardRectangleChanged, [&amp;]() {
        if (app-&gt;inputMethod()-&gt;keyboardRectangle().height() == 0)
                // keyboard is closed
                editor-&gt;setMaximumHeight(QWIDGETSIZE_MAX);
        else
                // keyboard is open, limit maximum vertical height
                editor-&gt;setMaximumHeight(editor-&gt;height());
});
</code></pre>
<p dir="auto">This happens to work for my use case, but might fail others...</p>
]]></description><link>https://forum.qt.io/post/835399</link><guid isPermaLink="true">https://forum.qt.io/post/835399</guid><dc:creator><![CDATA[bepispasta]]></dc:creator><pubDate>Tue, 13 Jan 2026 16:55:12 GMT</pubDate></item><item><title><![CDATA[Reply to QTextEdit goes underneath android keyboard when editing on Mon, 12 Jan 2026 17:34:30 GMT]]></title><description><![CDATA[<p dir="auto">Additionally, I've noticed that this also gets triggered when using the backspace key...</p>
]]></description><link>https://forum.qt.io/post/835385</link><guid isPermaLink="true">https://forum.qt.io/post/835385</guid><dc:creator><![CDATA[bepispasta]]></dc:creator><pubDate>Mon, 12 Jan 2026 17:34:30 GMT</pubDate></item><item><title><![CDATA[Reply to QTextEdit goes underneath android keyboard when editing on Mon, 12 Jan 2026 15:55:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Right!</p>
<p dir="auto">I'm using Qt 6.10.1 for android arm64-v8a (Android API lv 36), and I've tested on my phone, android 16 (ASP Nov. 1) with OneUI 8.0</p>
]]></description><link>https://forum.qt.io/post/835382</link><guid isPermaLink="true">https://forum.qt.io/post/835382</guid><dc:creator><![CDATA[bepispasta]]></dc:creator><pubDate>Mon, 12 Jan 2026 15:55:00 GMT</pubDate></item><item><title><![CDATA[Reply to QTextEdit goes underneath android keyboard when editing on Sun, 11 Jan 2026 19:28:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">You should add:</p>
<ul>
<li>Which version of Qt you are using</li>
<li>Which version of Android shows that issue</li>
</ul>
]]></description><link>https://forum.qt.io/post/835355</link><guid isPermaLink="true">https://forum.qt.io/post/835355</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 11 Jan 2026 19:28:09 GMT</pubDate></item></channel></rss>