Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QT QML Android Edge-to-Edge (notch screen) setup
Qt 6.11 is out! See what's new in the release blog

QT QML Android Edge-to-Edge (notch screen) setup

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 393 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.
  • A Offline
    A Offline
    al072072
    wrote last edited by al072072
    #1

    Hello, i am using Qt 6.11 Qt Quick android project on Windows 10 PC.

    AndroidManifest:

    <?xml version="1.0"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="org.qtproject.example.appRoboX"
        android:installLocation="auto"
        android:versionCode="1"
        android:versionName="1.0">
    
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-feature android:name="android.hardware.camera" android:required="true" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    
        <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
        <uses-feature android:name="android.hardware.opengl" android:required="true" />
        <supports-screens
            android:anyDensity="true"
            android:largeScreens="true"
            android:normalScreens="true"
            android:smallScreens="true" />
    
        <application
            android:name="org.qtproject.qt.android.bindings.QtApplication"
            android:hardwareAccelerated="true"
            android:label="RoboX"
            android:allowBackup="true"
            android:resizeableActivity="true"
            android:theme="@style/AppTheme"
            android:icon="@mipmap/ic_launcher">
    
            <uses-native-library android:name="libOpenCL.so"/>
    
            <activity
                android:name="org.qtproject.example.appRoboX.QtActivity"
                android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
                android:label="RoboX"
                android:launchMode="singleTop"
                android:screenOrientation="landscape"
                android:exported="true"
                android:theme="@style/AppTheme">
    
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    
                <meta-data
                    android:name="android.app.lib_name"
                    android:value="appRoboX" />
            </activity>
        </application>
    </manifest>
    

    QtActivity.java:

    package org.qtproject.example.appRoboX;
    
    import android.os.Bundle;
    import android.content.Intent;
    import android.util.Log;
    import androidx.annotation.NonNull;
    import android.view.View;
    import android.view.Window;
    import android.view.WindowManager;
    import android.os.Build;
    import androidx.core.view.WindowCompat;
    
    public class QtActivity extends org.qtproject.qt.android.bindings.QtActivity {
        private static final String TAG = "QtActivity";
    
    
       private void makeFullScreen() {
                Window window = getWindow();
                if (window != null) {
                    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                    window.getDecorView().setSystemUiVisibility(
                        View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN
                    );
                }
            }
    
    
        private void setCutoutMode() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                WindowManager.LayoutParams params = getWindow().getAttributes();
                params.layoutInDisplayCutoutMode =
                    WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
                getWindow().setAttributes(params);
            }
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
    
            setCutoutMode();
            makeFullScreen();
    
            Log.d(TAG, "QtActivity onCreate");
        }
    }
    

    Style.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="AppTheme" parent="@android:style/Theme.Black.NoTitleBar.Fullscreen">
            <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowFullscreen">true</item>
        </style>
    </resources>
    

    Main.qml:

    ApplicationWindow {
        id: mainWindow
        visible: true
        width: Screen.width
        height: Screen.height
        visibility: Window.FullScreen
        flags: Qt.Window | Qt.ExpandedClientAreaHint | Qt.NoTitleBarBackgroundHint
        color: "black"
    ...
    
     if (Qt.platform.os === "android") {
                mainWindow.showFullScreen()
                mainWindow.visibility = Window.FullScreen
            }
    }
    

    I am not able to activate cutof screen mode. If i set up it manually in Settings-Display->Cutoff it works fine.

    My question is how to programmatically setup Edge-to-Edge mode?

    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