What version of Qt
Qt 6.10.2
android are you targeting/using?
Are you referring to ANDROID_PLATFORM? its set to android-28 and I'm running it on a Pixel 4 simulator.
I created a new project with the following code:
import QtQuick.Controls
import QtQuick
import QtQuick.Layouts
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
onClosing: close => {
//Management for Android Back-Button
if (Qt.platform.os === "android") {
console.log("Accepting event")
close.accepted = false
} else {
close.accepted = true
}
}
}
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("helloqml", "Main");
return app.exec();
}
The console.log() message is being printed, but the app still minimizes.
ADB log:
D/qml : Accepting event
D/VRI[QtActivity]: visibilityChanged oldVisibility=true newVisibility=false
E/Surface : freeAllBuffers: 1 buffers were freed while being dequeued!
E/Surface : freeAllBuffers: 1 buffers were freed while being dequeued!
W/default : QRhiGles2: Failed to make context current. Expect bad things to happen.
W/default : Failed to start frame
W/WindowOnBackDispatcher: sendCancelIfRunning: isInProgress=false callback=android.app.Activity$$ExternalSyntheticLambda0@abe797f
D/qml : Accepting event