Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus
-
BTW: if you want to opt-out from Android-35 edge-to-edge
you have to add styles.xml and add in Manifest... activity... android:theme="@style/NormalTheme"
see the details here:
https://codereview.qt-project.org/c/qt/qtbase/+/630376@ekkescorner said in Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus:
BTW: if you want to opt-out from Android-35 edge-to-edge
you have to add styles.xml and add in Manifest... activity... android:theme="@style/NormalTheme"
see the details here:
https://codereview.qt-project.org/c/qt/qtbase/+/630376This worked for me...Thanks!
-
@ekkescorner said in Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus:
BTW: if you want to opt-out from Android-35 edge-to-edge
you have to add styles.xml and add in Manifest... activity... android:theme="@style/NormalTheme"
see the details here:
https://codereview.qt-project.org/c/qt/qtbase/+/630376This worked for me...Thanks!
@BTSTOnline cool :)
-
Problem
I want a simple Qt Quick app that does NOT draw under the notch / status bar / nav bar. I’m not going for immersive; I’m not setting
Qt.ExpandedClientAreaHint
. I bind my layout margins toSafeArea.margins.*
(similar to the Qt 6.9 blog post “Expanded Client Areas & Safe Areas” by Tor Arne Vestbø).Issue: On Android (targetSdk 35), at cold start my content still shows under the system bars. Debug logs show
SafeArea.margins = 0
. As soon as I tap a TextField (IME shows), SafeArea updates to non-zero and the layout snaps to the correct padded position.So it seems
SafeArea
isn’t initialized with valid insets until the first insets/resize event.Minimal-ish Repro (closer to my real app)
import QtQuick import QtQuick.Controls import QtQuick.Layouts import QtCore Window { id: root visible: true width: 360 height: 640 title: "Demo" // design padding in addition to SafeArea property int designPadding: 12 // SafeArea bindings property real safeTop: SafeArea.margins.top property real safeBottom: SafeArea.margins.bottom property real safeLeft: SafeArea.margins.left property real safeRight: SafeArea.margins.right // Debug: watch SafeArea Timer { interval: 500; running: true; repeat: true onTriggered: console.log("[safe]", root.safeTop, root.safeBottom, root.safeLeft, root.safeRight) } // Pretend persistent settings (trimmed) Settings { id: saved property string host: "" property string port: "" } // Layout that should be padded out of unsafe areas ColumnLayout { anchors.fill: parent anchors.topMargin: root.designPadding + root.safeTop anchors.bottomMargin: root.designPadding + root.safeBottom anchors.leftMargin: root.designPadding + root.safeLeft anchors.rightMargin: root.designPadding + root.safeRight spacing: 10 Label { text: "App" font.pixelSize: 24 Layout.alignment: Qt.AlignHCenter } TextField { id: hostInput Layout.fillWidth: true placeholderText: "Host" text: saved.host } TextField { id: portInput Layout.fillWidth: true placeholderText: "Port" text: saved.port.length ? saved.port : "5300" } Item { Layout.fillHeight: true } Button { text: "Connect" Layout.fillWidth: true } } }
Observed logs:
• Before tapping input: all SafeArea margins 0; content under status bar.
• After tapping input (IME): SafeArea margins become non-zero; layout correct.⸻
Extra: I tried forcing a 1-px geometry “nudge” after visible (resize there & back) to provoke inset delivery; did not help reliably.
Is this expected behavior for SafeArea on Android with a plain Window?
Should I be waiting for a specific signal, or just switch to ApplicationWindow for early safe-area padding?
If this looks like a bug/regression, happy to file a Qt bug report — let me know what data would help.Thanks!
-
I figured out a temporarily workaround by bringing up the virtual keyboard, which initializes the SafeArea margins correctly, and hide the keyboard immediately. At your constructor add this
connect(QGuiApplication::inputMethod(),SIGNAL(visibleChanged()),this,SLOT(closeKeyboard())); QGuiApplication::inputMethod()->show();
Then create a slot
void MyApp::closeKeyboard() { if (QGuiApplication::inputMethod()->isVisible()) { QGuiApplication::inputMethod()->hide(); disconnect(QGuiApplication::inputMethod(),SIGNAL(visibleChanged()),this,SLOT(closeKeyboard())); } }
On activation of the virtual keyboard, the visibleChanged() signal will trigger the closeKeyboard() slot. This hides the keyboard and disconnects the signal/slot. You may get a glimpse of keyboard animating in/out... I find this to be a reliable workaround and easiest to undo , once this bug is fixed.
-
Qt 6.9.3 should fix this and is scheduled for today - or coming soon ;-)
current state of Bugs around Safe Areas:
6.9.3:
- fixes getting SafeArea values at startup for Android 9 to 16, Android SplitScreen should also work
- (https://bugreports.qt.io/browse/QTBUG-135808)
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
- fixes Android orientation -flicker and half-screen-glitches
(https://bugreports.qt.io/browse/QTBUG-132718)
6.10.0:
- same as 6.9.3, BUT:
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
6.10.1:
- Android problems with color scheme fixed
- (https://bugreports.qt.io/browse/QTBUG-137248)
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
-
Qt 6.9.3 should fix this and is scheduled for today - or coming soon ;-)
current state of Bugs around Safe Areas:
6.9.3:
- fixes getting SafeArea values at startup for Android 9 to 16, Android SplitScreen should also work
- (https://bugreports.qt.io/browse/QTBUG-135808)
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
- fixes Android orientation -flicker and half-screen-glitches
(https://bugreports.qt.io/browse/QTBUG-132718)
6.10.0:
- same as 6.9.3, BUT:
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
6.10.1:
- Android problems with color scheme fixed
- (https://bugreports.qt.io/browse/QTBUG-137248)
- Android NavigationBar in SwipeViews and more fixed in 6.9.3 and 6.10.1, but NOT in 6.10.0 !
- (https://bugreports.qt.io/browse/QTBUG-139690)
@ekkescorner Thanks for the information Looking forward to the fix. I've been spending too much time, finding ways around this bug.
-
and 6.9.3 is here :) https://www.qt.io/blog/qt-6.9.3-released
edit: just did first tests with 6.9.3 on Android: now SafeArea values are there from start, also NavigationBar much better now :)
-
@ekkescorner Thanks for the information Looking forward to the fix. I've been spending too much time, finding ways around this bug.
@garycho said in Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus:
I've been spending too much time, finding ways around this bug
yep. always much time spending to report and follow all the bugreports and writing test applications like https://github.com/ekke/ekkesTestStatusBar
will update my test app next days with experiences from 6.9.3 -
and 6.9.3 is here :) https://www.qt.io/blog/qt-6.9.3-released
edit: just did first tests with 6.9.3 on Android: now SafeArea values are there from start, also NavigationBar much better now :)
@ekkescorner Excellent. Just compiled with 6.9.3 and the SafeArea margin is set correctly on start . The navigation bar is now grey instead of black.
-
@ekkescorner Excellent. Just compiled with 6.9.3 and the SafeArea margin is set correctly on start . The navigation bar is now grey instead of black.
@garycho said in Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus:
SafeArea margin is set correctly on start
great to hear that it also works for you :)