Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus
Forum Updated to NodeBB v4.3 + New Features

Android 15 (API 35) / Qt 6.9.1: SafeArea=0 at startup in plain Window; content under notch/nav until TextField focus

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
19 Posts 5 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Pann

    @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:

    @Pann this is a known bug for 6.9.1 see my bugreport https://bugreports.qt.io/browse/QTBUG-135808
    here's my ugly workaround:

    ApplicationWindow {
        ...
        contentOrientation: Qt.PortraitOrientation | Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation
        ..
        Component.onCompleted: {
            console.log("Orientation: ",contentOrientation)
    } 
    

    now there's a short flicker, but SafeArea gets the values
    should be fixed for 6.9.2 and probably 6.10.0 Beta2

    Thanks, @ekkescorner
    Unfortunately for me is not working, hope 6.9.2 will be released soon.
    Thanks!

    ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #4

    @Pann sorry I forgot these lines
    in ApplicationWindow:

    flags: Qt.platform.os === "android"? Qt.Window : Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint
    

    and Component.onCompleted:

    if(Qt.platform.os === "android") {
                window.flags = Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint
                window.visibility = Window.Windowed
            }
    

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.9 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BTSTOnline
      wrote on last edited by
      #5

      I've tried this solution (currently working with Qt 6.10)... and it has no effect.
      My app STILL shows up under the Status Bar and Navigation Bar on startup... Rotating to landscape and back fixes this... but, when in landscape, it shows up under the Nav Bar, but not the Status Bar.

      1 Reply Last reply
      0
      • ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #6

        just noticed that my workaround isn't always working :(
        runs on Android 14 Motorola Device, Android 13 Samsung Device,
        but fails on Android 15 Pixel9a Device
        seems we have to wait for 6.9.2: https://bugreports.qt.io/browse/QTBUG-135808

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.9 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        0
        • J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #7

          I actually react on the onCompleted

          Component.onCompleted: {
                  applyNewMargins()
              }
          

          to fetch the safe area margins

          function applyNewMargins(){
                  if(isMobile){
                      var map =           safeMargins.getSafeAreaMargins(mainWindow)
                      safeMarginLeft =    map["left"] * 2 / 3
                      safeMarginRight =   map["right"] * 2 / 3
                      safeMarginTop =     map["top"] * 2 / 3
                      safeMarginBottom =  map["bottom"] * 2 / 3
                  }
          }
          

          from my c++ backend. Haven't noticed any new timing issues. But this was ma solution way back in the day where the margins weren't available on application start. Don't see any flickering either


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #8

            thx for the info.
            I want to use the Qt 6.9 SafeArea. works well on iOS and hopefully with 6.9.2 on Android, too - so ATM I'll wait for 6.9.2

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.9 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            0
            • ekkescornerE Offline
              ekkescornerE Offline
              ekkescorner
              Qt Champions 2016
              wrote on last edited by
              #9

              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

              ekke ... Qt Champion 2016 | 2024 ... mobile business apps
              5.15 --> 6.9 https://t1p.de/ekkeChecklist
              QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

              B 1 Reply Last reply
              1
              • ekkescornerE ekkescorner

                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

                B Offline
                B Offline
                BTSTOnline
                wrote on last edited by
                #10

                @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/+/630376

                This worked for me...Thanks!

                ekkescornerE 1 Reply Last reply
                0
                • B BTSTOnline

                  @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/+/630376

                  This worked for me...Thanks!

                  ekkescornerE Offline
                  ekkescornerE Offline
                  ekkescorner
                  Qt Champions 2016
                  wrote on last edited by
                  #11

                  @BTSTOnline cool :)

                  ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                  5.15 --> 6.9 https://t1p.de/ekkeChecklist
                  QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                  1 Reply Last reply
                  0
                  • P Pann

                    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 to SafeArea.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!

                    G Offline
                    G Offline
                    garycho
                    wrote last edited by
                    #12

                    @Pann Tapping into a a TextField , brings up the virtual keyboard - this is what corrects the safeArea . Programmatically bring up the virtual keyboard to achieves the same effect.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      garycho
                      wrote last edited by garycho
                      #13

                      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.

                      1 Reply Last reply
                      0
                      • ekkescornerE Offline
                        ekkescornerE Offline
                        ekkescorner
                        Qt Champions 2016
                        wrote last edited by
                        #14

                        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)

                        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                        5.15 --> 6.9 https://t1p.de/ekkeChecklist
                        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                        G 1 Reply Last reply
                        0
                        • ekkescornerE ekkescorner

                          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)
                          G Offline
                          G Offline
                          garycho
                          wrote last edited by garycho
                          #15

                          @ekkescorner Thanks for the information Looking forward to the fix. I've been spending too much time, finding ways around this bug.

                          ekkescornerE 1 Reply Last reply
                          0
                          • ekkescornerE Offline
                            ekkescornerE Offline
                            ekkescorner
                            Qt Champions 2016
                            wrote last edited by ekkescorner
                            #16

                            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 :)

                            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                            5.15 --> 6.9 https://t1p.de/ekkeChecklist
                            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                            G 1 Reply Last reply
                            0
                            • G garycho

                              @ekkescorner Thanks for the information Looking forward to the fix. I've been spending too much time, finding ways around this bug.

                              ekkescornerE Offline
                              ekkescornerE Offline
                              ekkescorner
                              Qt Champions 2016
                              wrote last edited by
                              #17

                              @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

                              ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                              5.15 --> 6.9 https://t1p.de/ekkeChecklist
                              QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                              1 Reply Last reply
                              1
                              • ekkescornerE ekkescorner

                                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 :)

                                G Offline
                                G Offline
                                garycho
                                wrote last edited by
                                #18

                                @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.

                                ekkescornerE 1 Reply Last reply
                                0
                                • G garycho

                                  @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.

                                  ekkescornerE Offline
                                  ekkescornerE Offline
                                  ekkescorner
                                  Qt Champions 2016
                                  wrote last edited by
                                  #19

                                  @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 :)

                                  ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                                  5.15 --> 6.9 https://t1p.de/ekkeChecklist
                                  QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved