Qt for HarmonyOS/qtohosextras doc/QtOhosExtras Namespace: Difference between revisions
Created page with "<!-- Source: qtohosextras.html --> <span id="qtohosextras-namespace"></span> = QtOhosExtras Namespace = The QtOhosExtras namespace provides miscellaneous functions to aid Ohos development. More... <div class="table"> {| class="wikitable alignedsummary" |- | class="memItemLeft rightAlign topAlign"| Header: | class="memItemRight bottomAlign"| <span class="preprocessor">#include </span> |- | cl..." |
No edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
< | < [[Qt_for_HarmonyOS/qtohosextras_doc|Qt for HarmonyOS / qtohosextras doc]] | ||
= QtOhosExtras Namespace = | = QtOhosExtras Namespace = | ||
The | The QtOhosExtras namespace provides miscellaneous functions to aid Ohos development. [[#details|More...]] | ||
{| class="wikitable | {| class="wikitable" | ||
|- | |- | ||
! Header: | |||
| | | #include <QtOhosExtras> | ||
|- | |- | ||
! qmake: | |||
| QT += ohosextras | |||
|- | |- | ||
! Since: | |||
| Qt 5.12.12 | |||
|} | |} | ||
== Namespaces == | == Namespaces == | ||
{| class="wikitable" style="width:100%" | |||
|- | |- | ||
| namespace || '''[[FileShare_Namespace|FileShare]]''' || The FileShare to expose file permission API. | |||
| | |||
|- | |- | ||
| namespace || '''[[Qt for HarmonyOS/qtohosextras doc/QOhosPasteboard Namespace|QOhosPasteboard]]''' || The QOhosPasteboard class is to manage native pasteboard. | |||
| | |||
|- | |- | ||
| namespace || '''[[ShareKit_Namespace|ShareKit]]''' || The ShareKit to expose Share Kit API. | |||
| | |||
|} | |} | ||
== Classes == | == Classes == | ||
{| class="wikitable" style="width:100%" | |||
|- | |- | ||
| class | | class || '''[[QOhosAbilityContext_Class|QOhosAbilityContext]]''' || The QOhosAbilityContext class is to manage native UI Ability context. | ||
|- | |- | ||
| class | | class || '''[[QOhosAppContext_Class|QOhosAppContext]]''' || The QOhosAppContext class contains API to manage native application context. | ||
|- | |- | ||
| class | | class || '''[[QOhosBundleInfo_Class|QOhosBundleInfo]]''' || The QOhosBundleInfo class contains API to provide native application bundle info. | ||
|- | |- | ||
| class | | class || '''[[QOhosOnContinueContext_Class|QOhosOnContinueContext]]''' || The QOhosOnContinueContext class manages onContinue context. | ||
|- | |- | ||
| class | | class || '''[[QOhosOpenLinkOptions_Class|QOhosOpenLinkOptions]]''' || (No description) | ||
|- | |- | ||
| class | | class || '''[[QOhosOperationStatus_Class|QOhosOperationStatus]]''' || The QOhosOperationStatus class provides interface to get an opertaion status. | ||
|- | |- | ||
| class | | class || '''[[QOhosStartOptions_Class|QOhosStartOptions]]''' || The QOhosStartOptions class is to provide new options for new started ability or process. | ||
|- | |- | ||
| class | | class || '''[[Qt for HarmonyOS/qtohosextras doc/QOhosWant Class|QOhosWant]]''' || QOhosWant wraps Ohos Want class. | ||
|- | |- | ||
| class | | class || '''[[QOhosWantInfo_Class|QOhosWantInfo]]''' || The QOhosWantInfo class is to represent Ohos want type. | ||
|} | |} | ||
== Types == | == Types == | ||
{| class="wikitable" style="width:100%" | |||
|- | |- | ||
| enum || '''[[#CloseEventRootCause-enum|CloseEventRootCause]]''' || { InternalClose, AbilityClose, WindowStageClose } | |||
| | |||
|- | |- | ||
| enum || '''[[#QOhosWantFlag-enum|QOhosWantFlag]]''' || { AuthReadUriPermission, AuthWriteUriPermission, InstallOnDemand } | |||
| | |||
|- | |- | ||
| flags || '''[[#QOhosWantFlag-enum|QOhosWantFlag]]''' || (Typedef for QFlags<QOhosWantFlag>) | |||
| | |||
|- | |- | ||
| enum || '''[[#WindowGeometryPersistenceHint-enum|WindowGeometryPersistenceHint]]''' || { Disabled, Enabled, FollowSystemSetting } | |||
| | |||
|} | |} | ||
== Functions == | == Functions == | ||
{| class="wikitable" style="width:100%" | |||
|- | |- | ||
| bool || '''[[#authorizeFilePath|authorizeFilePath]]'''(QWindow *''parentWindow'', const QString &''filePath'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosWantInfo> || '''[[#convertToOhosExtrasWantInfo|convertToOhosExtrasWantInfo]]'''(int ''wantInfo'') | |||
| | |||
|- | |- | ||
| int || '''[[#convertToQpaWantInfo|convertToQpaWantInfo]]'''(QSharedPointer<QtOhosExtras::QOhosWantInfo>) | |||
| | |||
|- | |- | ||
| QtOhosExtras::QOhosWant || '''[[#convertWantFromJsonObject|convertWantFromJsonObject]]'''(const QJsonObject &''jsonWant'') | |||
| | |||
|- | |- | ||
| QJsonObject || '''[[#convertWantToJsonObject|convertWantToJsonObject]]'''(const QtOhosExtras::QOhosWant &''want'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosOpenLinkOptions> || '''[[#createOpenLinkOptions|createOpenLinkOptions]]'''() | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosStartOptions> || '''[[#createStartOptions|createStartOptions]]'''() | |||
| | |||
|- | |- | ||
| QtOhosExtras::CloseEventRootCause || '''[[#getCloseEventRootCause|getCloseEventRootCause]]'''(QCloseEvent *''closeEvent'') | |||
| | |||
|- | |- | ||
| bool || '''[[#moveFileToTrash|moveFileToTrash]]'''(const QString &''filePath'') | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::QOhosAppContext::ColorThemeMode) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::QOhosStartOptions::ProcessMode) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::QOhosStartOptions::StartupVisibility) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::QOhosStartOptions::WindowMode) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::QOhosStartOptions::SupportWindowMode) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::CloseEventRootCause) | |||
| | |||
|- | |- | ||
| const QMetaObject * || '''qt_getEnumMetaObject'''(QtOhosExtras::WindowGeometryPersistenceHint) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::QOhosAppContext::ColorThemeMode) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::QOhosStartOptions::ProcessMode) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::QOhosStartOptions::StartupVisibility) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::QOhosStartOptions::WindowMode) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::QOhosStartOptions::SupportWindowMode) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::CloseEventRootCause) | |||
| | |||
|- | |- | ||
| const char * || '''qt_getEnumName'''(QtOhosExtras::WindowGeometryPersistenceHint) | |||
| | |||
|- | |- | ||
| void || '''[[#requestQOhosPermissionFromUserIfNeeded|requestQOhosPermissionFromUserIfNeeded]]'''(QObject *''resultConsumerQtContext'', QWindow *''optInstanceMainWindow'', const QString &''permissionName'', int ''resultConsumer'') | |||
| | |||
|- | |- | ||
| void || '''[[#requestQOhosPermissionOnSettingIfNeeded|requestQOhosPermissionOnSettingIfNeeded]]'''(QObject *''resultConsumerQtContext'', QWindow *''optInstanceMainWindow'', int ''permission'', int ''resultConsumer'') | |||
| | |||
|- | |- | ||
| void || '''[[#setAbilityInstanceDestroyEnabled|setAbilityInstanceDestroyEnabled]]'''(QWindow *''instanceWindow'', bool ''destroyEnabled'') | |||
| | |||
|- | |- | ||
| void || '''[[#setBundledAbilityAndQWindowBindingKeyForQWindow|setBundledAbilityAndQWindowBindingKeyForQWindow]]'''(QWindow *''window'', const QString &''qAbilityQWindowBindingKey'') | |||
| | |||
|- | |- | ||
| void || '''[[#setMainWindowGeometryPersistenceHint|setMainWindowGeometryPersistenceHint]]'''(QtOhosExtras::WindowGeometryPersistenceHint ''geometryPersistenceHint'') | |||
| | |||
|- | |- | ||
| void || '''[[#setShowWindowAsFloatWindowHint|setShowWindowAsFloatWindowHint]]'''(QWindow *''window'', bool ''showAsFloatWindow'') | |||
| | |||
|- | |- | ||
| void || '''[[#setShowWindowAsFloatWindowHint-1|setShowWindowAsFloatWindowHint]]'''(QWidget *''widget'', bool ''showAsFloatWindow'') | |||
| | |||
|- | |- | ||
| void || '''[[#setSurfaceBackgroundColor|setSurfaceBackgroundColor]]'''(QWindow *''window'', const QColor &''color'') | |||
| | |||
|- | |- | ||
| void || '''[[#setSurfaceBackgroundColor-1|setSurfaceBackgroundColor]]'''(QWidget *''widget'', const QColor &''color'') | |||
| | |||
|- | |- | ||
| void || '''[[#setWindowCornerRadius|setWindowCornerRadius]]'''(QWindow *''window'', double ''radius'') | |||
| | |||
|- | |- | ||
| void || '''[[#setWindowCornerRadius-1|setWindowCornerRadius]]'''(QWidget *''widget'', double ''radius'') | |||
| | |||
|- | |- | ||
| void || '''[[#setWindowKeepScreenOn|setWindowKeepScreenOn]]'''(QWindow *''window'', bool ''keepScreenOn'') | |||
| | |||
|- | |- | ||
| void || '''[[#setWindowKeepScreenOn-1|setWindowKeepScreenOn]]'''(QWidget *''widget'', bool ''keepScreenOn'') | |||
| | |||
|- | |- | ||
| void || '''[[#setWindowPrivacyMode|setWindowPrivacyMode]]'''(QWindow *''window'', bool ''privacyModeEnabled'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> || '''[[#startAbility|startAbility]]'''(const QtOhosExtras::QOhosWant &''want'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> || '''[[#startAbility-1|startAbility]]'''(const QtOhosExtras::QOhosWant &''want'', const QtOhosExtras::QOhosStartOptions &''options'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> || '''[[#startAbilityByType|startAbilityByType]]'''(const QString &''appType'', const QJsonObject &''wantParameters'') | |||
| | |||
|- | |- | ||
| void || '''[[#startAppProcess|startAppProcess]]'''(const QString &''processId'', const QtOhosExtras::QOhosWant &''requestWant'') | |||
| | |||
|- | |- | ||
| void || '''[[#startAppProcess-1|startAppProcess]]'''(const QString &''processId'', const QtOhosExtras::QOhosWant &''requestWant'', const QtOhosExtras::QOhosStartOptions &''options'') | |||
| | |||
|- | |- | ||
| void || '''[[#startNewAbilityInstance|startNewAbilityInstance]]'''(QWidget *''instanceWidget'') | |||
| | |||
|- | |- | ||
| QSharedPointer<double> || '''[[#tryGetNativeWindowId|tryGetNativeWindowId]]'''(QWindow *''window'') | |||
| | |||
|- | |- | ||
| QSharedPointer<QByteArray> || '''[[#tryGetOnContinueData|tryGetOnContinueData]]'''(const QtOhosExtras::QOhosWant &''want'') | |||
| | |||
|- | |- | ||
| QSharedPointer<double> || '''[[#tryGetScreenDisplayId|tryGetScreenDisplayId]]'''(QScreen *''screen'') | |||
| | |||
|- | |- | ||
| int || '''[[#tryMapQOhosPermissionFromName|tryMapQOhosPermissionFromName]]'''(const QString &) | |||
| | |||
|- | |- | ||
| int || '''[[#tryMapQOhosPermissionToName|tryMapQOhosPermissionToName]]'''(int) | |||
| | |||
|- | |- | ||
| QFlags<QOhosWantFlags::enum_type> || '''[[#operator-7c|operator\|]]'''(QOhosWantFlags::enum_type ''f1'', QOhosWantFlags::enum_type ''f2'') | |||
| | |||
|- | |- | ||
| QFlags<QOhosWantFlags::enum_type> || '''[[#operator-7c-1|operator\|]]'''(QOhosWantFlags::enum_type ''f1'', QFlags<QOhosWantFlags::enum_type> ''f2'') | |||
| | |||
|- | |- | ||
| QIncompatibleFlag || '''[[#operator-7c-2|operator\|]]'''(QOhosWantFlags::enum_type ''f1'', int ''f2'') | |||
| | |||
|} | |} | ||
== Detailed Description == | |||
<span id="details"></span> | <span id="details"></span> | ||
The QtOhosExtras namespace provides miscellaneous functions to aid Ohos development. | |||
The | |||
== Type Documentation == | == Type Documentation == | ||
=== <span id="CloseEventRootCause-enum"></span>enum QtOhosExtras::CloseEventRootCause === | |||
=== <span id="CloseEventRootCause-enum"></span>enum QtOhosExtras:: | |||
Enumerates the close event root cause. | Enumerates the close event root cause. | ||
{| class="wikitable" | |||
! Constant !! Value !! Description | |||
{| class="wikitable | |||
! | |||
! | |||
! | |||
|- | |- | ||
| | | QtOhosExtras::InternalClose || 0 || Close root cause not specified or unknown. | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::AbilityClose || 1 || Close root cause of preparing to terminate. | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::WindowStageClose || 2 || Close root cause of native Window Stage or Sub-Window close. | ||
| | |||
| | |||
|} | |} | ||
This enum was introduced or modified in Qt 5.12.12. | This enum was introduced or modified in Qt 5.12.12. | ||
=== <span id="QOhosWantFlag-enum"></span>enum QtOhosExtras::QOhosWantFlag<br/>flags QtOhosExtras::QOhosWantFlags === | |||
=== <span id="QOhosWantFlag-enum"></span>enum QtOhosExtras:: | |||
flags QtOhosExtras:: | |||
QOhosWantFlag specifies how the Want will be handled. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-ability-wantconstant-V5#flags Flags]. | QOhosWantFlag specifies how the Want will be handled. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-ability-wantconstant-V5#flags Flags]. | ||
{| class="wikitable" | |||
! Constant !! Value !! Description | |||
{| class="wikitable | |||
! | |||
! | |||
! | |||
|- | |- | ||
| | | QtOhosExtras::AuthReadUriPermission || 1 << 0 || Grants the permission to read the URI. | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::AuthWriteUriPermission || 1 << 1 || Grants the permission to write data to the URI. | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::InstallOnDemand || 1 << 2 || Ability will be installed if it has not been installed. | ||
| | |||
| | |||
|} | |} | ||
This enum was introduced or modified in Qt 5.12.12. | This enum was introduced or modified in Qt 5.12.12. | ||
The QOhosWantFlags type is a typedef for | The QOhosWantFlags type is a typedef for QFlags<QOhosWantFlag>. It stores an OR combination of QOhosWantFlag values. | ||
=== <span id="WindowGeometryPersistenceHint-enum"></span>enum QtOhosExtras::WindowGeometryPersistenceHint === | |||
=== <span id="WindowGeometryPersistenceHint-enum"></span>enum QtOhosExtras:: | |||
Enumerates the policy for window geometry persistence support. Specifies how a window’s geometry (the size and position) is determined when it is shown. | Enumerates the policy for window geometry persistence support. Specifies how a window’s geometry (the size and position) is determined when it is shown. | ||
{| class="wikitable" | |||
! Constant !! Value !! Description | |||
{| class="wikitable | |||
! | |||
! | |||
! | |||
|- | |- | ||
| | | QtOhosExtras::Disabled || 0 || Use default window's geometry. | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::Enabled || 1 || Restore previous window's geometry (position and size when before window was closed). | ||
| | |||
| | |||
|- | |- | ||
| | | QtOhosExtras::FollowSystemSetting || 2 || Let the system decide whether to use Disabled or Enabled value. | ||
| | |||
| | |||
|} | |} | ||
This enum was introduced or modified in Qt 5.12.12. | This enum was introduced or modified in Qt 5.12.12. | ||
== Function Documentation == | == Function Documentation == | ||
=== <span id="authorizeFilePath"></span>bool QtOhosExtras::authorizeFilePath(QWindow *parentWindow, const QString &filePath) === | |||
=== <span id="authorizeFilePath"></span | |||
Request authorization on the User selected ''parentWindow'' for a given ''filePath''. The system File Dialog in authorization mode will be presented to the User. According to User choice returns true if file path is authorized, false otherwise. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-file-picker#documentselectoptions authMode] | Request authorization on the User selected ''parentWindow'' for a given ''filePath''. The system File Dialog in authorization mode will be presented to the User. According to User choice returns true if file path is authorized, false otherwise. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-file-picker#documentselectoptions authMode]. | ||
This function was introduced in Qt 5.12.12. | This function was introduced in Qt 5.12.12. | ||
<span id="convertToOhosExtrasWantInfo"></span> | === <span id="convertToOhosExtrasWantInfo"></span>QSharedPointer<QtOhosExtras::QOhosWantInfo> QtOhosExtras::convertToOhosExtrasWantInfo(int wantInfo) === | ||
(No description provided in source) | |||
QSharedPointer<QtOhosExtras::QOhosWantInfo> QtOhosExtras::convertToOhosExtrasWantInfo(int | |||
< | === <span id="createStartOptions"></span>QSharedPointer<QtOhosExtras::QOhosStartOptions> QtOhosExtras::createStartOptions() === | ||
QSharedPointer<QtOhosExtras::QOhosStartOptions> QtOhosExtras::createStartOptions() | |||
Creates | Creates QOhosStartOptions instance. | ||
=== <span id="getCloseEventRootCause"></span>QtOhosExtras::CloseEventRootCause QtOhosExtras::getCloseEventRootCause(QCloseEvent *closeEvent) === | |||
=== <span id="getCloseEventRootCause"></span> | |||
Converts a given ''closeEvent'' to | Converts a given ''closeEvent'' to QtOhosExtras::CloseEventRootCause. | ||
Returns related | Returns related QtOhosExtras::CloseEventRootCause value. | ||
=== <span id="moveFileToTrash"></span>bool QtOhosExtras::moveFileToTrash(const QString &filePath) === | |||
=== <span id="moveFileToTrash"></span | |||
Moves the file specified by ''filePath'' to the trash. Returns true if successful, false otherwise. | Moves the file specified by ''filePath'' to the trash. Returns true if successful, false otherwise. | ||
| Line 527: | Line 255: | ||
This function provides functionality of QFile::moveToTrash() from Qt 5.15. | This function provides functionality of QFile::moveToTrash() from Qt 5.15. | ||
=== <span id="setAbilityInstanceDestroyEnabled"></span>void QtOhosExtras::setAbilityInstanceDestroyEnabled(QWindow *instanceWindow, bool destroyEnabled) === | |||
<span id=" | |||
Sets whether the Ability related with ''instanceWindow'' can be automatically destroyed by the system when the user clicks on the window's "close" button. If ''destroyEnabled'' is true, the system destroys the Ability automatically (and Qt needs to adapt to this). If ''destroyEnabled'' = false, the window is not automatically destroyed, but instead standard Qt path for window close is triggered, i.e. QWindow::close(). | |||
By default, the flag is set to false. | |||
'''See also:''' QtOhosExtras::QOhosAbilityContext::setDestroyFromSystemEnabled(). | |||
=== <span id="setMainWindowGeometryPersistenceHint"></span>void QtOhosExtras::setMainWindowGeometryPersistenceHint(QtOhosExtras::WindowGeometryPersistenceHint geometryPersistenceHint) === | |||
=== <span id="setMainWindowGeometryPersistenceHint"></span | |||
Sets a given ''geometryPersistenceHint'' on first main window shown. | Sets a given ''geometryPersistenceHint'' on first main window shown. | ||
| Line 600: | Line 275: | ||
Read about details in [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window#setwindowrectautosave here]. | Read about details in [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window#setwindowrectautosave here]. | ||
=== <span id="setShowWindowAsFloatWindowHint"></span>void QtOhosExtras::setShowWindowAsFloatWindowHint(QWindow *window, bool showAsFloatWindow) === | |||
=== <span id="setShowWindowAsFloatWindowHint"></span | |||
Sets or unsets a given ''window'' as floating window according to ''showAsFloatWindow'' flag. Read more about floating window type [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5 here]. | Sets or unsets a given ''window'' as floating window according to ''showAsFloatWindow'' flag. Read more about floating window type [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5 here]. | ||
| Line 608: | Line 282: | ||
auto window = std::make_unique<MainWindow>(); | auto window = std::make_unique<MainWindow>(); | ||
QtOhosExtras::setShowWindowAsFloatWindowHint(window.get(), true); | QtOhosExtras::setShowWindowAsFloatWindowHint(window.get(), true); | ||
window->show();</syntaxhighlight> | window->show(); | ||
</syntaxhighlight> | |||
=== <span id="setShowWindowAsFloatWindowHint-1"></span | |||
=== <span id="setShowWindowAsFloatWindowHint-1"></span>void QtOhosExtras::setShowWindowAsFloatWindowHint(QWidget *widget, bool showAsFloatWindow) === | |||
Sets or unsets a given ''widget'' as floating window according to ''showAsFloatWindow'' flag. Read more about floating window type [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5 here]. | Sets or unsets a given ''widget'' as floating window according to ''showAsFloatWindow'' flag. Read more about floating window type [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5 here]. | ||
=== <span id="setSurfaceBackgroundColor"></span>void QtOhosExtras::setSurfaceBackgroundColor(QWindow *window, const QColor &color) === | |||
=== <span id="setSurfaceBackgroundColor"></span | |||
Sets a given ''color'' as background color on the ''window'' inner native layer. | Sets a given ''color'' as background color on the ''window'' inner native layer. | ||
=== <span id="setSurfaceBackgroundColor-1"></span>void QtOhosExtras::setSurfaceBackgroundColor(QWidget *widget, const QColor &color) === | |||
=== <span id="setSurfaceBackgroundColor-1"></span | |||
Sets a given ''color'' as background color on the ''widget'' inner native layer. | Sets a given ''color'' as background color on the ''widget'' inner native layer. | ||
| Line 626: | Line 299: | ||
'''Warning:''' Currently, dynamic color change on a widget is not supported yet. | '''Warning:''' Currently, dynamic color change on a widget is not supported yet. | ||
=== <span id="setWindowCornerRadius"></span>void QtOhosExtras::setWindowCornerRadius(QWindow *window, double radius) === | |||
=== <span id="setWindowCornerRadius"></span | |||
Sets corner ''radius'' for a ''window''. Given ''window'' has to be a sub or floating window type. It can be achieved for example: - by setting | Sets corner ''radius'' for a ''window''. Given ''window'' has to be a sub or floating window type. It can be achieved for example: - by setting Qt::WindowFlags, like: Qt::Window, Qt::Popup, Qt::Dialog etc. - explicitly using QtOhosExtras::setShowWindowAsFloatWindowHint() function. More on windows in: [https://doc.qt.io/archives/qt-5.15/qwindow.html Qt official docs]. The ''radius'' must not be a negative number. There's no upper limit in value, although visually OHOS uses maximum achievable value. In order for this function to work properly, it has to be called before the window is shown. | ||
Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window here]. | Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window here]. | ||
=== <span id="setWindowCornerRadius-1"></span>void QtOhosExtras::setWindowCornerRadius(QWidget *widget, double radius) === | |||
=== <span id="setWindowCornerRadius-1"></span | |||
Sets corner ''radius'' for a ''widget''. Given ''widget'' has to be formed as a new window, it means it cannot be embedded in a parent widget. It can be achieved for example: - by setting | Sets corner ''radius'' for a ''widget''. Given ''widget'' has to be formed as a new window, it means it cannot be embedded in a parent widget. It can be achieved for example: - by setting Qt::WindowFlags, like: Qt::Window, Qt::Popup, Qt::Dialog etc. - explicitly using QtOhosExtras::setShowWindowAsFloatWindowHint() function. More on widgets as windows in: [https://doc.qt.io/archives/qt-5.15/qwidget.html Qt official docs]. The ''radius'' must not be a negative number. There's no upper limit in value, although visually OHOS uses maximum achievable value. In order for this function to work properly, it has to be called before the widget is shown. | ||
Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window here]. | Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references/js-apis-window here]. | ||
=== <span id="setWindowKeepScreenOn"></span>void QtOhosExtras::setWindowKeepScreenOn(QWindow *window, bool keepScreenOn) === | |||
=== <span id="setWindowKeepScreenOn"></span | |||
Sets or unsets a given ''window'' to keep the screen on according to ''keepScreenOn'' flag. | Sets or unsets a given ''window'' to keep the screen on according to ''keepScreenOn'' flag. | ||
| Line 647: | Line 317: | ||
Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowkeepscreenon here]. | Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowkeepscreenon here]. | ||
=== <span id="setWindowKeepScreenOn-1"></span>void QtOhosExtras::setWindowKeepScreenOn(QWidget *widget, bool keepScreenOn) === | |||
=== <span id="setWindowKeepScreenOn-1"></span | |||
Sets or unsets a given ''widget'' to keep the screen on according to ''keepScreenOn'' flag. | Sets or unsets a given ''widget'' to keep the screen on according to ''keepScreenOn'' flag. | ||
| Line 654: | Line 323: | ||
Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowkeepscreenon here]. | Read more: [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowkeepscreenon here]. | ||
=== <span id="setWindowPrivacyMode"></span>void QtOhosExtras::setWindowPrivacyMode(QWindow *window, bool privacyModeEnabled) === | |||
=== <span id="setWindowPrivacyMode"></span | |||
Change window privacy mode according to a given ''window'' and ''privacyModeEnabled''. Read more about window privacy mode [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowprivacymode9 here] | Change window privacy mode according to a given ''window'' and ''privacyModeEnabled''. Read more about window privacy mode [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#setwindowprivacymode9 here] | ||
<span id="startAbility"></span> | === <span id="startAbility"></span>QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbility(const QtOhosExtras::QOhosWant &want) === | ||
QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbility(const QtOhosExtras::QOhosWant & | |||
Starts an Ability for a given ''want''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartability Start Ability]. | Starts an Ability for a given ''want''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartability Start Ability]. | ||
'''Warning:''' Currently, operation status result is hardcoded as | '''Warning:''' Currently, operation status result is hardcoded as "successful" (even if ability were not started). | ||
< | === <span id="startAbility-1"></span>QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbility(const QtOhosExtras::QOhosWant &want, const QtOhosExtras::QOhosStartOptions &options) === | ||
QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbility(const QtOhosExtras::QOhosWant & | |||
Starts an Ability for a given ''want'' and ''options''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartability-1 Start Ability]. | Starts an Ability for a given ''want'' and ''options''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartability-1 Start Ability]. | ||
'''Warning:''' Currently, operation status result is hardcoded as | '''Warning:''' Currently, operation status result is hardcoded as "successful" (even if ability were not started). | ||
< | === <span id="startAbilityByType"></span>QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbilityByType(const QString &appType, const QJsonObject &wantParameters) === | ||
QSharedPointer<QtOhosExtras::QOhosOperationStatus> QtOhosExtras::startAbilityByType(const QString & | |||
Starts an Ability for a given ''appType'' and ''wantParameters''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartabilitybytype11-1 Start Ability]. | Starts an Ability for a given ''appType'' and ''wantParameters''. See [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-inner-application-uiabilitycontext-V5#uiabilitycontextstartabilitybytype11-1 Start Ability]. | ||
Returns true on success | Returns true on success. | ||
=== <span id="startAppProcess"></span>void QtOhosExtras::startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant) === | |||
=== <span id="startAppProcess"></span | |||
Starts application process for a given ''processId'' and ''requestWant''. | Starts application process for a given ''processId'' and ''requestWant''. | ||
=== <span id="startAppProcess-1"></span>void QtOhosExtras::startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant, const QtOhosExtras::QOhosStartOptions &options) === | |||
=== <span id="startAppProcess-1"></span | |||
Starts application process for a given ''processId'', ''requestWant'' and ''options''. | Starts application process for a given ''processId'', ''requestWant'' and ''options''. | ||
=== <span id="startNewAbilityInstance"></span>void QtOhosExtras::startNewAbilityInstance(QWidget *instanceWidget) === | |||
=== <span id="startNewAbilityInstance"></span | |||
Starts another instance of the UIAbility used by the Qt app with specified widget inside | Starts another instance of the UIAbility used by the Qt app with specified widget inside. | ||
The caller should pass newly created | The caller should pass newly created QWidget ''instanceWidget'', without any setting any parent, calling show() or winId() on it. | ||
<span id="tryGetNativeWindowId"></span> | === <span id="tryGetNativeWindowId"></span>QSharedPointer<double> QtOhosExtras::tryGetNativeWindowId(QWindow *window) === | ||
Function tries to obtain native window ID (ID associated with system window object) of given ''window''. The failure of the operation is indicated by returned value equal to `nullptr`. | |||
Function tries to obtain native window ID (ID associated with system window object) of given ''window''. The failure of the operation is indicated by returned value equal to | |||
'''Note:''' This function must be called only after the ''window'' has been shown. | '''Note:''' This function must be called only after the ''window'' has been shown. | ||
| Line 722: | Line 367: | ||
'''Warning:''' Returned native window ID isn't guaranteed to be valid throughout the lifetime of application. Application stability and performance may be poor after using this function, use it at your own risk! | '''Warning:''' Returned native window ID isn't guaranteed to be valid throughout the lifetime of application. Application stability and performance may be poor after using this function, use it at your own risk! | ||
Read more on native window ID (WindowProperties.id): [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#windowproperties here] | Read more on native window ID (WindowProperties.id): [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-window-V5#windowproperties here]. | ||
< | === <span id="tryGetOnContinueData"></span>QSharedPointer<QByteArray> QtOhosExtras::tryGetOnContinueData(const QtOhosExtras::QOhosWant &want) === | ||
QSharedPointer<QByteArray> QtOhosExtras::tryGetOnContinueData(const QtOhosExtras::QOhosWant & | (No description provided in source) | ||
<span id="tryGetScreenDisplayId"></span> | === <span id="tryGetScreenDisplayId"></span>QSharedPointer<double> QtOhosExtras::tryGetScreenDisplayId(QScreen *screen) === | ||
Function tries to obtain native display ID of given ''screen''. The failure of the operation is indicated by returning `nullptr`. | |||
Read more on display ID (Display.id): [https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/js-apis-display-V5#display here]. | |||
=== <span id="tryMapQOhosPermissionFromName"></span>int QtOhosExtras::tryMapQOhosPermissionFromName(const QString &) === | |||
=== <span id="tryMapQOhosPermissionToName"></span>int QtOhosExtras::tryMapQOhosPermissionToName(int) === | |||
=== <span id=" | |||
=== <span id="operator-7c"></span>QFlags<QOhosWantFlags::enum_type> QtOhosExtras::operator|(QOhosWantFlags::enum_type f1, QOhosWantFlags::enum_type f2) === | |||
=== <span id=" | |||
=== <span id="operator-7c-1"></span>QFlags<QOhosWantFlags::enum_type> QtOhosExtras::operator|(QOhosWantFlags::enum_type f1, QFlags<QOhosWantFlags::enum_type> f2) === | |||
<span id="operator-7c-1"></span> | |||
QFlags<QOhosWantFlags::enum_type> QtOhosExtras::operator|(QOhosWantFlags::enum_type | |||
=== <span id="operator-7c-2"></span>QIncompatibleFlag QtOhosExtras::operator|(QOhosWantFlags::enum_type f1, int f2) === | |||
=== <span id="operator-7c-2"></span> | |||
[[Category:Qt for HarmonyOS]] | |||
Latest revision as of 08:17, 29 January 2026
< Qt for HarmonyOS / qtohosextras doc
QtOhosExtras Namespace
The QtOhosExtras namespace provides miscellaneous functions to aid Ohos development. More...
| Header: | #include <QtOhosExtras> |
|---|---|
| qmake: | QT += ohosextras |
| Since: | Qt 5.12.12 |
Namespaces
| namespace | FileShare | The FileShare to expose file permission API. |
| namespace | QOhosPasteboard | The QOhosPasteboard class is to manage native pasteboard. |
| namespace | ShareKit | The ShareKit to expose Share Kit API. |
Classes
| class | QOhosAbilityContext | The QOhosAbilityContext class is to manage native UI Ability context. |
| class | QOhosAppContext | The QOhosAppContext class contains API to manage native application context. |
| class | QOhosBundleInfo | The QOhosBundleInfo class contains API to provide native application bundle info. |
| class | QOhosOnContinueContext | The QOhosOnContinueContext class manages onContinue context. |
| class | QOhosOpenLinkOptions | (No description) |
| class | QOhosOperationStatus | The QOhosOperationStatus class provides interface to get an opertaion status. |
| class | QOhosStartOptions | The QOhosStartOptions class is to provide new options for new started ability or process. |
| class | QOhosWant | QOhosWant wraps Ohos Want class. |
| class | QOhosWantInfo | The QOhosWantInfo class is to represent Ohos want type. |
Types
| enum | CloseEventRootCause | { InternalClose, AbilityClose, WindowStageClose } |
| enum | QOhosWantFlag | { AuthReadUriPermission, AuthWriteUriPermission, InstallOnDemand } |
| flags | QOhosWantFlag | (Typedef for QFlags<QOhosWantFlag>) |
| enum | WindowGeometryPersistenceHint | { Disabled, Enabled, FollowSystemSetting } |
Functions
| bool | authorizeFilePath(QWindow *parentWindow, const QString &filePath) |
| QSharedPointer<QtOhosExtras::QOhosWantInfo> | convertToOhosExtrasWantInfo(int wantInfo) |
| int | convertToQpaWantInfo(QSharedPointer<QtOhosExtras::QOhosWantInfo>) |
| QtOhosExtras::QOhosWant | convertWantFromJsonObject(const QJsonObject &jsonWant) |
| QJsonObject | convertWantToJsonObject(const QtOhosExtras::QOhosWant &want) |
| QSharedPointer<QtOhosExtras::QOhosOpenLinkOptions> | createOpenLinkOptions() |
| QSharedPointer<QtOhosExtras::QOhosStartOptions> | createStartOptions() |
| QtOhosExtras::CloseEventRootCause | getCloseEventRootCause(QCloseEvent *closeEvent) |
| bool | moveFileToTrash(const QString &filePath) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::QOhosAppContext::ColorThemeMode) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::QOhosStartOptions::ProcessMode) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::QOhosStartOptions::StartupVisibility) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::QOhosStartOptions::WindowMode) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::QOhosStartOptions::SupportWindowMode) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::CloseEventRootCause) |
| const QMetaObject * | qt_getEnumMetaObject(QtOhosExtras::WindowGeometryPersistenceHint) |
| const char * | qt_getEnumName(QtOhosExtras::QOhosAppContext::ColorThemeMode) |
| const char * | qt_getEnumName(QtOhosExtras::QOhosStartOptions::ProcessMode) |
| const char * | qt_getEnumName(QtOhosExtras::QOhosStartOptions::StartupVisibility) |
| const char * | qt_getEnumName(QtOhosExtras::QOhosStartOptions::WindowMode) |
| const char * | qt_getEnumName(QtOhosExtras::QOhosStartOptions::SupportWindowMode) |
| const char * | qt_getEnumName(QtOhosExtras::CloseEventRootCause) |
| const char * | qt_getEnumName(QtOhosExtras::WindowGeometryPersistenceHint) |
| void | requestQOhosPermissionFromUserIfNeeded(QObject *resultConsumerQtContext, QWindow *optInstanceMainWindow, const QString &permissionName, int resultConsumer) |
| void | requestQOhosPermissionOnSettingIfNeeded(QObject *resultConsumerQtContext, QWindow *optInstanceMainWindow, int permission, int resultConsumer) |
| void | setAbilityInstanceDestroyEnabled(QWindow *instanceWindow, bool destroyEnabled) |
| void | setBundledAbilityAndQWindowBindingKeyForQWindow(QWindow *window, const QString &qAbilityQWindowBindingKey) |
| void | setMainWindowGeometryPersistenceHint(QtOhosExtras::WindowGeometryPersistenceHint geometryPersistenceHint) |
| void | setShowWindowAsFloatWindowHint(QWindow *window, bool showAsFloatWindow) |
| void | setShowWindowAsFloatWindowHint(QWidget *widget, bool showAsFloatWindow) |
| void | setSurfaceBackgroundColor(QWindow *window, const QColor &color) |
| void | setSurfaceBackgroundColor(QWidget *widget, const QColor &color) |
| void | setWindowCornerRadius(QWindow *window, double radius) |
| void | setWindowCornerRadius(QWidget *widget, double radius) |
| void | setWindowKeepScreenOn(QWindow *window, bool keepScreenOn) |
| void | setWindowKeepScreenOn(QWidget *widget, bool keepScreenOn) |
| void | setWindowPrivacyMode(QWindow *window, bool privacyModeEnabled) |
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> | startAbility(const QtOhosExtras::QOhosWant &want) |
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> | startAbility(const QtOhosExtras::QOhosWant &want, const QtOhosExtras::QOhosStartOptions &options) |
| QSharedPointer<QtOhosExtras::QOhosOperationStatus> | startAbilityByType(const QString &appType, const QJsonObject &wantParameters) |
| void | startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant) |
| void | startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant, const QtOhosExtras::QOhosStartOptions &options) |
| void | startNewAbilityInstance(QWidget *instanceWidget) |
| QSharedPointer<double> | tryGetNativeWindowId(QWindow *window) |
| QSharedPointer<QByteArray> | tryGetOnContinueData(const QtOhosExtras::QOhosWant &want) |
| QSharedPointer<double> | tryGetScreenDisplayId(QScreen *screen) |
| int | tryMapQOhosPermissionFromName(const QString &) |
| int | tryMapQOhosPermissionToName(int) |
| QFlags<QOhosWantFlags::enum_type> | operator\|(QOhosWantFlags::enum_type f1, QOhosWantFlags::enum_type f2) |
| QFlags<QOhosWantFlags::enum_type> | operator\|(QOhosWantFlags::enum_type f1, QFlags<QOhosWantFlags::enum_type> f2) |
| QIncompatibleFlag | operator\|(QOhosWantFlags::enum_type f1, int f2) |
Detailed Description
The QtOhosExtras namespace provides miscellaneous functions to aid Ohos development.
Type Documentation
enum QtOhosExtras::CloseEventRootCause
Enumerates the close event root cause.
| Constant | Value | Description |
|---|---|---|
| QtOhosExtras::InternalClose | 0 | Close root cause not specified or unknown. |
| QtOhosExtras::AbilityClose | 1 | Close root cause of preparing to terminate. |
| QtOhosExtras::WindowStageClose | 2 | Close root cause of native Window Stage or Sub-Window close. |
This enum was introduced or modified in Qt 5.12.12.
enum QtOhosExtras::QOhosWantFlag
flags QtOhosExtras::QOhosWantFlags
QOhosWantFlag specifies how the Want will be handled. See Flags.
| Constant | Value | Description |
|---|---|---|
| QtOhosExtras::AuthReadUriPermission | 1 << 0 | Grants the permission to read the URI. |
| QtOhosExtras::AuthWriteUriPermission | 1 << 1 | Grants the permission to write data to the URI. |
| QtOhosExtras::InstallOnDemand | 1 << 2 | Ability will be installed if it has not been installed. |
This enum was introduced or modified in Qt 5.12.12.
The QOhosWantFlags type is a typedef for QFlags<QOhosWantFlag>. It stores an OR combination of QOhosWantFlag values.
enum QtOhosExtras::WindowGeometryPersistenceHint
Enumerates the policy for window geometry persistence support. Specifies how a window’s geometry (the size and position) is determined when it is shown.
| Constant | Value | Description |
|---|---|---|
| QtOhosExtras::Disabled | 0 | Use default window's geometry. |
| QtOhosExtras::Enabled | 1 | Restore previous window's geometry (position and size when before window was closed). |
| QtOhosExtras::FollowSystemSetting | 2 | Let the system decide whether to use Disabled or Enabled value. |
This enum was introduced or modified in Qt 5.12.12.
Function Documentation
bool QtOhosExtras::authorizeFilePath(QWindow *parentWindow, const QString &filePath)
Request authorization on the User selected parentWindow for a given filePath. The system File Dialog in authorization mode will be presented to the User. According to User choice returns true if file path is authorized, false otherwise. See authMode.
This function was introduced in Qt 5.12.12.
(No description provided in source)
Creates QOhosStartOptions instance.
QtOhosExtras::CloseEventRootCause QtOhosExtras::getCloseEventRootCause(QCloseEvent *closeEvent)
Converts a given closeEvent to QtOhosExtras::CloseEventRootCause.
Returns related QtOhosExtras::CloseEventRootCause value.
bool QtOhosExtras::moveFileToTrash(const QString &filePath)
Moves the file specified by filePath to the trash. Returns true if successful, false otherwise.
This function provides functionality of QFile::moveToTrash() from Qt 5.15.
void QtOhosExtras::setAbilityInstanceDestroyEnabled(QWindow *instanceWindow, bool destroyEnabled)
Sets whether the Ability related with instanceWindow can be automatically destroyed by the system when the user clicks on the window's "close" button. If destroyEnabled is true, the system destroys the Ability automatically (and Qt needs to adapt to this). If destroyEnabled = false, the window is not automatically destroyed, but instead standard Qt path for window close is triggered, i.e. QWindow::close().
By default, the flag is set to false.
See also: QtOhosExtras::QOhosAbilityContext::setDestroyFromSystemEnabled().
void QtOhosExtras::setMainWindowGeometryPersistenceHint(QtOhosExtras::WindowGeometryPersistenceHint geometryPersistenceHint)
Sets a given geometryPersistenceHint on first main window shown.
If this function is called with geometryPersistenceHint `Enabled`, the first main window's geometry will be saved when the window is closed and restored on the next application launch. By default this feature is disabled.
This method must be called before first main window is shown. Otherwise geometry persistence policy will not be updated.
Only supported on 2-in-1 devices.
Read about details in here.
void QtOhosExtras::setShowWindowAsFloatWindowHint(QWindow *window, bool showAsFloatWindow)
Sets or unsets a given window as floating window according to showAsFloatWindow flag. Read more about floating window type here.
auto window = std::make_unique<MainWindow>();
QtOhosExtras::setShowWindowAsFloatWindowHint(window.get(), true);
window->show();void QtOhosExtras::setShowWindowAsFloatWindowHint(QWidget *widget, bool showAsFloatWindow)
Sets or unsets a given widget as floating window according to showAsFloatWindow flag. Read more about floating window type here.
void QtOhosExtras::setSurfaceBackgroundColor(QWindow *window, const QColor &color)
Sets a given color as background color on the window inner native layer.
void QtOhosExtras::setSurfaceBackgroundColor(QWidget *widget, const QColor &color)
Sets a given color as background color on the widget inner native layer.
Warning: Currently, dynamic color change on a widget is not supported yet.
void QtOhosExtras::setWindowCornerRadius(QWindow *window, double radius)
Sets corner radius for a window. Given window has to be a sub or floating window type. It can be achieved for example: - by setting Qt::WindowFlags, like: Qt::Window, Qt::Popup, Qt::Dialog etc. - explicitly using QtOhosExtras::setShowWindowAsFloatWindowHint() function. More on windows in: Qt official docs. The radius must not be a negative number. There's no upper limit in value, although visually OHOS uses maximum achievable value. In order for this function to work properly, it has to be called before the window is shown.
Read more: here.
void QtOhosExtras::setWindowCornerRadius(QWidget *widget, double radius)
Sets corner radius for a widget. Given widget has to be formed as a new window, it means it cannot be embedded in a parent widget. It can be achieved for example: - by setting Qt::WindowFlags, like: Qt::Window, Qt::Popup, Qt::Dialog etc. - explicitly using QtOhosExtras::setShowWindowAsFloatWindowHint() function. More on widgets as windows in: Qt official docs. The radius must not be a negative number. There's no upper limit in value, although visually OHOS uses maximum achievable value. In order for this function to work properly, it has to be called before the widget is shown.
Read more: here.
void QtOhosExtras::setWindowKeepScreenOn(QWindow *window, bool keepScreenOn)
Sets or unsets a given window to keep the screen on according to keepScreenOn flag.
Read more: here.
void QtOhosExtras::setWindowKeepScreenOn(QWidget *widget, bool keepScreenOn)
Sets or unsets a given widget to keep the screen on according to keepScreenOn flag.
Read more: here.
void QtOhosExtras::setWindowPrivacyMode(QWindow *window, bool privacyModeEnabled)
Change window privacy mode according to a given window and privacyModeEnabled. Read more about window privacy mode here
Starts an Ability for a given want. See Start Ability.
Warning: Currently, operation status result is hardcoded as "successful" (even if ability were not started).
Starts an Ability for a given want and options. See Start Ability.
Warning: Currently, operation status result is hardcoded as "successful" (even if ability were not started).
Starts an Ability for a given appType and wantParameters. See Start Ability.
Returns true on success.
void QtOhosExtras::startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant)
Starts application process for a given processId and requestWant.
void QtOhosExtras::startAppProcess(const QString &processId, const QtOhosExtras::QOhosWant &requestWant, const QtOhosExtras::QOhosStartOptions &options)
Starts application process for a given processId, requestWant and options.
void QtOhosExtras::startNewAbilityInstance(QWidget *instanceWidget)
Starts another instance of the UIAbility used by the Qt app with specified widget inside.
The caller should pass newly created QWidget instanceWidget, without any setting any parent, calling show() or winId() on it.
Function tries to obtain native window ID (ID associated with system window object) of given window. The failure of the operation is indicated by returned value equal to `nullptr`.
Note: This function must be called only after the window has been shown.
Warning: Returned native window ID isn't guaranteed to be valid throughout the lifetime of application. Application stability and performance may be poor after using this function, use it at your own risk!
Read more on native window ID (WindowProperties.id): here.
(No description provided in source)
Function tries to obtain native display ID of given screen. The failure of the operation is indicated by returning `nullptr`.
Read more on display ID (Display.id): here.