Jump to content

Qt for HarmonyOS/qtohosextras doc/Bundled Embedded UI Extension Example: Difference between revisions

From Qt Wiki
Add example documentation from qdoc output (QTFOROH-2307)
 
Drop manual breadcrumb, MediaWiki renders it automatically (QTFOROH-2307)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
< [[Qt_for_HarmonyOS/qtohosextras_doc|Qt for HarmonyOS / qtohosextras doc]]
= Bundled Embedded UI Extension Example =
= Bundled Embedded UI Extension Example =


Line 8: Line 6:


The example creates two identical windows, each containing a label and a button that rewrites the label text. Each window is bound to a QBundledEmbeddedUiExtensionAbility instance with QtOhosExtras::setBundledAbilityAndQWindowBindingKeyForQWindow(), using the binding keys <code>"A"</code> and <code>"B"</code>. The underlying [https://doc.qt.io/qt-5/qwindow.html QWindow] is created up front by calling [https://doc.qt.io/qt-5/qwidget.html#winId QWidget::winId]() before the binding function is invoked.
The example creates two identical windows, each containing a label and a button that rewrites the label text. Each window is bound to a QBundledEmbeddedUiExtensionAbility instance with QtOhosExtras::setBundledAbilityAndQWindowBindingKeyForQWindow(), using the binding keys <code>"A"</code> and <code>"B"</code>. The underlying [https://doc.qt.io/qt-5/qwindow.html QWindow] is created up front by calling [https://doc.qt.io/qt-5/qwidget.html#winId QWidget::winId]() before the binding function is invoked.
<syntaxhighlight lang="cpp">
    QString windowAQAbilityBindingKey = "A";
    auto windowA = makeBundledUiExtensionWindow(windowAQAbilityBindingKey);
    QtOhosExtras::setBundledAbilityAndQWindowBindingKeyForQWindow(
        getOrCreateUnderlyingQWindow(windowA.get()),
        windowAQAbilityBindingKey);
</syntaxhighlight>


'''Note: '''The bound windows must have no parent or transient parent and must not be shown by the application. A window becomes visible only when the extension ability instance whose want carries the matching <code>io.qt.public.bundledAbilityAndQWindowBindingKey</code> parameter is started.
'''Note: '''The bound windows must have no parent or transient parent and must not be shown by the application. A window becomes visible only when the extension ability instance whose want carries the matching <code>io.qt.public.bundledAbilityAndQWindowBindingKey</code> parameter is started.
Line 13: Line 21:
Files:
Files:


* [[Qt_for_HarmonyOS/qtohosextras_doc/Bundled_Embedded_UI_Extension_Example|bundledembeddeduiextension/bundledembeddeduiextension.pro]]
* [[Qt_for_HarmonyOS/qtohosextras_doc/Bundled_Embedded_UI_Extension_Example_-_bundledembeddeduiextension.pro|bundledembeddeduiextension/bundledembeddeduiextension.pro]]
* [[Qt_for_HarmonyOS/qtohosextras_doc/Bundled_Embedded_UI_Extension_Example|bundledembeddeduiextension/main.cpp]]
* [[Qt_for_HarmonyOS/qtohosextras_doc/Bundled_Embedded_UI_Extension_Example_-_main.cpp|bundledembeddeduiextension/main.cpp]]


[[Category:Qt for HarmonyOS]]
[[Category:Qt for HarmonyOS]]

Latest revision as of 05:22, 17 September 2026

Bundled Embedded UI Extension Example

Demonstrates binding Qt windows to bundled EmbeddedUIExtensionAbility instances by key.


The example creates two identical windows, each containing a label and a button that rewrites the label text. Each window is bound to a QBundledEmbeddedUiExtensionAbility instance with QtOhosExtras::setBundledAbilityAndQWindowBindingKeyForQWindow(), using the binding keys "A" and "B". The underlying QWindow is created up front by calling QWidget::winId() before the binding function is invoked.

     QString windowAQAbilityBindingKey = "A";
     auto windowA = makeBundledUiExtensionWindow(windowAQAbilityBindingKey);
     QtOhosExtras::setBundledAbilityAndQWindowBindingKeyForQWindow(
         getOrCreateUnderlyingQWindow(windowA.get()),
         windowAQAbilityBindingKey);

Note: The bound windows must have no parent or transient parent and must not be shown by the application. A window becomes visible only when the extension ability instance whose want carries the matching io.qt.public.bundledAbilityAndQWindowBindingKey parameter is started.

Files: