QNativeInterface::QAndroidApplication Struct
Android의 핵심 애플리케이션을 위한 네이티브 인터페이스. 더 보기...
| 헤더: | #include <QCoreApplication> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| 다음부터: | Qt 6.2부터 |
- 상속된 멤버를 포함한 모든 멤버 목록
- QAndroidApplication은 Native Interfaces의 일부입니다.
공개 함수
| QAndroidApplication() | |
| QAndroidApplication(const QNativeInterface::QAndroidApplication &) | |
| QAndroidApplication(QNativeInterface::QAndroidApplication &&) | |
| QNativeInterface::QAndroidApplication & | operator=(QNativeInterface::QAndroidApplication &&) |
| QNativeInterface::QAndroidApplication & | operator=(const QNativeInterface::QAndroidApplication &) |
정적 공용 멤버
(since 6.2) QJniObject | context() |
(since 6.2) void | hideSplashScreen(int duration = 0) |
(since 6.2) bool | isActivityContext() |
(since 6.2) QFuture<QVariant> | runOnAndroidMainThread(const std::function<QVariant ()> &runnable, const QDeadlineTimer timeout = QDeadlineTimer::Forever) |
(since 6.2) int | sdkVersion() |
멤버 함수 설명
[constexpr noexcept default] QAndroidApplication::QAndroidApplication()
QAndroidApplication 의 인스턴스를 기본 생성합니다.
[delete] QAndroidApplication::QAndroidApplication(const QNativeInterface::QAndroidApplication &)
QAndroidApplication 의 인스턴스를 복사 생성합니다. 이 함수는 삭제되었습니다.
[delete] QAndroidApplication::QAndroidApplication(QNativeInterface::QAndroidApplication &&)
QAndroidApplication 의 인스턴스를 move-construct로 생성합니다. 이 함수는 삭제되었습니다.
[static, since 6.2] QJniObject QAndroidApplication::context()
Android 컨텍스트를 ` QtJniTypes::Context`로 반환합니다. 가장 최근에 시작된 액티비티 객체가 유효한 경우, 컨텍스트는 ` Activity `입니다. 그렇지 않은 경우, 컨텍스트는 ` Service`입니다.
이 함수는 Qt 6.2에서 도입되었습니다.
[static, since 6.2] void QAndroidApplication::hideSplashScreen(int duration = 0)
지정된 ` duration`에 페이드 효과를 적용하여 스플래시 화면을 숨깁니다. ` duration `가 지정되지 않은 경우(기본값은 0), 앱이 시작된 직후 스플래시 화면이 즉시 숨겨집니다.
이 함수는 Qt 6.2에서 도입되었습니다.
[static, since 6.2] bool QAndroidApplication::isActivityContext()
QAndroidApplication::context()가 Activity 컨텍스트를 반환하는 경우, true 를 반환합니다.
이 함수는 Qt 6.2에서 도입되었습니다.
[static, since 6.2] QFuture<QVariant> QAndroidApplication::runOnAndroidMainThread(const std::function<QVariant ()> &runnable, const QDeadlineTimer timeout = QDeadlineTimer::Forever)
runnable 함수를 Android 스레드에 게시합니다. 이 함수는 큐에 추가된 후 Android UI 스레드에서 실행됩니다. Android UI 스레드에서 호출할 경우 runnable 가 즉시 실행됩니다. Android 앱이 일시 중지되었거나 메인 액티비티가 null인 경우, runnable 가 Android 메인 스레드의 큐에 추가됩니다.
이 호출은 QFuture<QVariant>를 반환하며, 이를 통해 동기 및 비동기 호출을 모두 수행할 수 있고 모든 반환 유형을 처리할 수 있습니다. 그러나 QFuture::result()에서 결과를 가져오려면 QVariant::value()를 사용해야 합니다.
runnable 의 실행 시간이 timeout 의 기간보다 길 경우, timeout 가 경과하면 QFuture::waitForFinished() 및 QFuture::result()과 같은 차단 호출은 종료됩니다. 그러나 runnable 의 실행이 이미 시작된 경우에는 취소되지 않습니다.
다음 예제는 반환 유형을 기대하는 비동기 호출을 실행하는 방법을 보여줍니다:
auto task = QNativeInterface::QAndroidApplication::runOnAndroidMainThread([=]() {
QJniObject surfaceView;
if (!surfaceView.isValid())
qDebug() << "SurfaceView object is not valid yet";
surfaceView = QJniObject("android/view/SurfaceView",
"(Landroid/content/Context;)V",
QNativeInterface::QAndroidApplication::context());
return QVariant::fromValue(surfaceView);
}).then([](QFuture<QVariant> future) {
auto surfaceView = future.result().value<QJniObject>();
if (surfaceView.isValid())
qDebug() << "Retrieved SurfaceView object is valid";
});다음 예제는 반환 유형이 void인 동기 호출을 실행하는 방법을 보여줍니다:
QNativeInterface::QAndroidApplication::runOnAndroidMainThread([]() {
QJniObject activity = QNativeInterface::QAndroidApplication::context();
// Hide system ui elements or go full screen
activity.callObjectMethod("getWindow", "()Landroid/view/Window;")
.callObjectMethod("getDecorView", "()Landroid/view/View;")
.callMethod<void>("setSystemUiVisibility", "(I)V", 0xffffffff);
}).waitForFinished();참고: Android의 메인 스레드에서 수행하는 작업의 유형에주의해야 합니다 . 시간이 오래 걸리는 작업은 앱의 UI 렌더링과 입력 처리를 차단할 수 있기 때문입니다. 함수의 실행 시간이 길 것으로 예상되는 경우, runnable 에서 QDeadlineTimer 를 사용하여 실행을 관리하고 UI 스레드가 차단되지 않도록 하는 것이 좋습니다. 일반적으로 5초 이상 소요되는 작업은 앱의 UI를 차단할 수 있습니다. 자세한 내용은 ‘앱의 반응성 유지’를 참조하세요.
이 함수는 Qt 6.2에서 도입되었습니다.
[static, since 6.2] int QAndroidApplication::sdkVersion()
Android SDK 버전을 반환합니다. 이를 API 레벨이라고도 합니다.
이 함수는 Qt 6.2에서 도입되었습니다.
[delete] QNativeInterface::QAndroidApplication &QAndroidApplication::operator=(QNativeInterface::QAndroidApplication &&)
other 을 이 QAndroidApplication 인스턴스에 할당합니다. 이 함수는 삭제됩니다.
[delete] QNativeInterface::QAndroidApplication &QAndroidApplication::operator=(const QNativeInterface::QAndroidApplication &)
other 을 이 QAndroidApplication 인스턴스에 복사-할당합니다. 이 함수는 삭제되었습니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.