Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicklabsplatformmenu.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
9
10#include <QtCore/qloggingcategory.h>
11#include <QtGui/qicon.h>
12#include <QtGui/qcursor.h>
13#include <QtGui/qpa/qplatformtheme.h>
14#include <QtGui/private/qguiapplication_p.h>
15#include <QtGui/private/qhighdpiscaling_p.h>
16#include <QtQml/private/qqmlengine_p.h>
17#include <QtQml/private/qv4scopedvalue_p.h>
18#include <QtQml/private/qv4qobjectwrapper_p.h>
19#include <QtQuick/qquickrendercontrol.h>
20#include <QtQuick/qquickwindow.h>
21#include <QtQuick/qquickitem.h>
22
23#include "widgets/qwidgetplatform_p.h"
24
25#if QT_CONFIG(systemtrayicon)
26#include "qquicklabsplatformsystemtrayicon_p.h"
27#endif
28
30
31/*!
32 \qmltype Menu
33 \inherits QtObject
34//! \nativetype QQuickLabsPlatformMenu
35 \inqmlmodule Qt.labs.platform
36 \since 5.8
37 \brief A native menu.
38
39 The Menu type provides a QML API for native platform menu popups.
40
41 \image {qtlabsplatform-menu.png} {A native popup menu}
42
43 Menu can be used in a \l MenuBar, or as a stand-alone context menu.
44 The following example shows how to open a context menu on right mouse
45 click:
46
47 \code
48 MouseArea {
49 anchors.fill: parent
50 acceptedButtons: Qt.RightButton
51 onClicked: zoomMenu.open()
52 }
53
54 Menu {
55 id: zoomMenu
56
57 MenuItem {
58 text: qsTr("Zoom In")
59 shortcut: StandardKey.ZoomIn
60 onTriggered: zoomIn()
61 }
62
63 MenuItem {
64 text: qsTr("Zoom Out")
65 shortcut: StandardKey.ZoomOut
66 onTriggered: zoomOut()
67 }
68 }
69 \endcode
70
71 \section2 Submenus
72
73 To create submenus, declare a Menu as a child of another Menu:
74
75 \qml
76 Menu {
77 title: qsTr("Edit")
78
79 Menu {
80 title: qsTr("Advanced")
81
82 MenuItem {
83 text: qsTr("Auto-indent Selection")
84 onTriggered: autoIndentSelection()
85 }
86
87 MenuItem {
88 text: qsTr("Rewrap Paragraph")
89 onTriggered: rewrapParagraph()
90 }
91 }
92 }
93 \endqml
94
95 \section2 Dynamically generating menu items
96
97 You can dynamically generate menu items with \l Instantiator. The following
98 code shows how you can implement a "Recent Files" submenu, where the items
99 come from a list of files stored in settings:
100
101 \snippet qtlabsplatform-menu-instantiator.qml menu
102
103 \section2 Availability
104
105 A native platform menu is currently available on the following platforms:
106
107 \list
108 \li macOS
109 \li iOS
110 \li Android
111 \li Linux (only available as a stand-alone context menu when running with the GTK+ platform theme)
112 \endlist
113
114 \input includes/widgets.qdocinc 1
115
116 \labs
117
118 \sa MenuItem, MenuSeparator, MenuBar
119*/
120
121/*!
122 \qmlsignal Qt.labs.platform::Menu::aboutToShow()
123
124 This signal is emitted when the menu is about to be shown to the user.
125*/
126
127/*!
128 \qmlsignal Qt.labs.platform::Menu::aboutToHide()
129
130 This signal is emitted when the menu is about to be hidden from the user.
131*/
132
133Q_LOGGING_CATEGORY(qtLabsPlatformMenus, "qt.labs.platform.menus")
134
135QQuickLabsPlatformMenu::QQuickLabsPlatformMenu(QObject *parent)
136 : QObject(parent),
137 m_complete(false),
138 m_enabled(true),
139 m_visible(true),
140 m_minimumWidth(-1),
141 m_type(QPlatformMenu::DefaultMenu),
142 m_menuBar(nullptr),
143 m_parentMenu(nullptr),
144 m_systemTrayIcon(nullptr),
145 m_menuItem(nullptr),
146 m_iconLoader(nullptr),
147 m_handle(nullptr)
148{
149}
150
152{
153 if (m_menuBar)
154 m_menuBar->removeMenu(this);
155 if (m_parentMenu)
156 m_parentMenu->removeMenu(this);
157
158 unparentSubmenus();
159
160 delete m_iconLoader;
161 m_iconLoader = nullptr;
162 delete m_handle;
163 m_handle = nullptr;
164}
165
166void QQuickLabsPlatformMenu::unparentSubmenus()
167{
168 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
169 if (QQuickLabsPlatformMenu *subMenu = item->subMenu())
170 subMenu->setParentMenu(nullptr);
171 item->setMenu(nullptr);
172 }
173}
174
175QPlatformMenu *QQuickLabsPlatformMenu::handle() const
176{
177 return m_handle;
178}
179
181{
182 if (!m_handle) {
183 if (m_menuBar && m_menuBar->handle())
184 m_handle = m_menuBar->handle()->createMenu();
185 else if (m_parentMenu && m_parentMenu->handle())
186 m_handle = m_parentMenu->handle()->createSubMenu();
187#if QT_CONFIG(systemtrayicon)
188 else if (m_systemTrayIcon && m_systemTrayIcon->handle())
189 m_handle = m_systemTrayIcon->handle()->createMenu();
190#endif
191
192 // TODO: implement ^
193 // - QCocoaMenuBar::createMenu()
194 // - QCocoaMenu::createSubMenu()
195 // - QCocoaSystemTrayIcon::createMenu()
196 if (!m_handle)
197 m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
198
199 if (!m_handle)
200 m_handle = QWidgetPlatform::createMenu();
201
202 qCDebug(qtLabsPlatformMenus) << "Menu ->" << m_handle;
203
204 if (m_handle) {
205 connect(m_handle, &QPlatformMenu::aboutToShow, this, &QQuickLabsPlatformMenu::aboutToShow);
206 connect(m_handle, &QPlatformMenu::aboutToHide, this, &QQuickLabsPlatformMenu::aboutToHide);
207
208 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
209 m_handle->insertMenuItem(item->create(), nullptr);
210
211 if (m_menuItem) {
212 if (QPlatformMenuItem *handle = m_menuItem->create())
213 handle->setMenu(m_handle);
214 }
215 }
216 }
217 return m_handle;
218}
219
221{
222 if (!m_handle)
223 return;
224
225 // Ensure that all submenus are unparented before we are destroyed,
226 // so that they don't try to access a destroyed menu.
227 unparentSubmenus();
228
229 delete m_handle;
230 m_handle = nullptr;
231}
232
234{
235 if (!m_complete || !create())
236 return;
237
238 m_handle->setText(m_title);
239 m_handle->setEnabled(m_enabled);
240 m_handle->setVisible(m_visible);
241 m_handle->setMinimumWidth(m_minimumWidth);
242 m_handle->setMenuType(m_type);
243 m_handle->setFont(m_font);
244
245 if (m_menuBar && m_menuBar->handle())
246 m_menuBar->handle()->syncMenu(m_handle);
247#if QT_CONFIG(systemtrayicon)
248 else if (m_systemTrayIcon && m_systemTrayIcon->handle())
249 m_systemTrayIcon->handle()->updateMenu(m_handle);
250#endif
251
252 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items))
253 item->sync();
254}
255
256/*!
257 \qmldefault
258 \qmlproperty list<QtObject> Qt.labs.platform::Menu::data
259
260 This default property holds the list of all objects declared as children of
261 the menu. The data property includes objects that are not \l MenuItem instances,
262 such as \l Timer and \l QtObject.
263
264 \sa items
265*/
267{
268 return QQmlListProperty<QObject>(this, nullptr, data_append, data_count, data_at, data_clear);
269}
270
271/*!
272 \qmlproperty list<MenuItem> Qt.labs.platform::Menu::items
273
274 This property holds the list of items in the menu.
275*/
277{
278 return QQmlListProperty<QQuickLabsPlatformMenuItem>(this, nullptr, items_append, items_count, items_at, items_clear);
279}
280
281/*!
282 \readonly
283 \qmlproperty MenuBar Qt.labs.platform::Menu::menuBar
284
285 This property holds the menubar that the menu belongs to, or \c null if the
286 menu is not in a menubar.
287*/
289{
290 return m_menuBar;
291}
292
294{
295 if (m_menuBar == menuBar)
296 return;
297
298 m_menuBar = menuBar;
299 destroy();
300 emit menuBarChanged();
301}
302
303/*!
304 \readonly
305 \qmlproperty Menu Qt.labs.platform::Menu::parentMenu
306
307 This property holds the parent menu that the menu belongs to, or \c null if the
308 menu is not a sub-menu.
309*/
311{
312 return m_parentMenu;
313}
314
316{
317 if (m_parentMenu == menu)
318 return;
319
320 m_parentMenu = menu;
321 destroy();
322 emit parentMenuChanged();
323}
324
325#if QT_CONFIG(systemtrayicon)
326/*!
327 \readonly
328 \qmlproperty SystemTrayIcon Qt.labs.platform::Menu::systemTrayIcon
329
330 This property holds the system tray icon that the menu belongs to, or \c null
331 if the menu is not in a system tray icon.
332*/
333QQuickLabsPlatformSystemTrayIcon *QQuickLabsPlatformMenu::systemTrayIcon() const
334{
335 return m_systemTrayIcon;
336}
337
338void QQuickLabsPlatformMenu::setSystemTrayIcon(QQuickLabsPlatformSystemTrayIcon *icon)
339{
340 if (m_systemTrayIcon == icon)
341 return;
342
343 m_systemTrayIcon = icon;
344 destroy();
345 emit systemTrayIconChanged();
346}
347#endif
348
349/*!
350 \readonly
351 \qmlproperty MenuItem Qt.labs.platform::Menu::menuItem
352
353 This property holds the item that presents the menu (in a parent menu).
354*/
356{
357 if (!m_menuItem) {
358 QQuickLabsPlatformMenu *that = const_cast<QQuickLabsPlatformMenu *>(this);
359 m_menuItem = new QQuickLabsPlatformMenuItem(that);
360 m_menuItem->setSubMenu(that);
361 m_menuItem->setText(m_title);
362 m_menuItem->setIcon(icon());
363 m_menuItem->setVisible(m_visible);
364 m_menuItem->setEnabled(m_enabled);
365 m_menuItem->componentComplete();
366 }
367 return m_menuItem;
368}
369
370/*!
371 \qmlproperty bool Qt.labs.platform::Menu::enabled
372
373 This property holds whether the menu is enabled. The default value is \c true.
374*/
376{
377 return m_enabled;
378}
379
381{
382 if (m_enabled == enabled)
383 return;
384
385 if (m_menuItem)
386 m_menuItem->setEnabled(enabled);
387
388 m_enabled = enabled;
389 sync();
390 emit enabledChanged();
391}
392
393/*!
394 \qmlproperty bool Qt.labs.platform::Menu::visible
395
396 This property holds whether the menu is visible. The default value is \c true.
397*/
399{
400 return m_visible;
401}
402
404{
405 if (m_visible == visible)
406 return;
407
408 if (m_menuItem)
409 m_menuItem->setVisible(visible);
410
411 m_visible = visible;
412 sync();
413 emit visibleChanged();
414}
415
416/*!
417 \qmlproperty int Qt.labs.platform::Menu::minimumWidth
418
419 This property holds the minimum width of the menu. The default value is \c -1 (no minimum width).
420*/
422{
423 return m_minimumWidth;
424}
425
427{
428 if (m_minimumWidth == width)
429 return;
430
431 m_minimumWidth = width;
432 sync();
433 emit minimumWidthChanged();
434}
435
436/*!
437 \qmlproperty enumeration Qt.labs.platform::Menu::type
438
439 This property holds the type of the menu.
440
441 Available values:
442 \value Menu.DefaultMenu A normal menu (default).
443 \value Menu.EditMenu An edit menu with pre-populated cut, copy and paste items.
444*/
446{
447 return m_type;
448}
449
450void QQuickLabsPlatformMenu::setType(QPlatformMenu::MenuType type)
451{
452 if (m_type == type)
453 return;
454
455 m_type = type;
456 sync();
457 emit typeChanged();
458}
459
460/*!
461 \qmlproperty string Qt.labs.platform::Menu::title
462
463 This property holds the menu's title.
464*/
466{
467 return m_title;
468}
469
470void QQuickLabsPlatformMenu::setTitle(const QString &title)
471{
472 if (m_title == title)
473 return;
474
475 if (m_menuItem)
476 m_menuItem->setText(title);
477
478 m_title = title;
479 sync();
480 emit titleChanged();
481}
482
483/*!
484 \qmlproperty font Qt.labs.platform::Menu::font
485
486 This property holds the menu's font.
487
488 \sa title
489*/
491{
492 return m_font;
493}
494
495void QQuickLabsPlatformMenu::setFont(const QFont& font)
496{
497 if (m_font == font)
498 return;
499
500 m_font = font;
501 sync();
502 emit fontChanged();
503}
504
505/*!
506 \since Qt.labs.platform 1.1 (Qt 5.12)
507 \qmlproperty url Qt.labs.platform::Menu::icon.source
508 \qmlproperty string Qt.labs.platform::Menu::icon.name
509 \qmlproperty bool Qt.labs.platform::Menu::icon.mask
510
511 This property holds the menu item's icon.
512*/
514{
515 if (!m_iconLoader)
516 return QQuickLabsPlatformIcon();
517
519}
520
522{
523 if (iconLoader()->icon() == icon)
524 return;
525
526 if (m_menuItem)
527 m_menuItem->setIcon(icon);
528
530 emit iconChanged();
531}
532
533/*!
534 \qmlmethod void Qt.labs.platform::Menu::addItem(MenuItem item)
535
536 Adds an \a item to the end of the menu.
537*/
539{
540 insertItem(m_items.size(), item);
541}
542
543/*!
544 \qmlmethod void Qt.labs.platform::Menu::insertItem(int index, MenuItem item)
545
546 Inserts an \a item at the specified \a index in the menu.
547*/
549{
550 if (!item || m_items.contains(item))
551 return;
552
553 m_items.insert(index, item);
554 m_data.append(item);
555 item->setMenu(this);
556 if (m_handle && item->create()) {
557 QQuickLabsPlatformMenuItem *before = m_items.value(index + 1);
558 m_handle->insertMenuItem(item->handle(), before ? before->create() : nullptr);
559 }
560 sync();
561 emit itemsChanged();
562}
563
564/*!
565 \qmlmethod void Qt.labs.platform::Menu::removeItem(MenuItem item)
566
567 Removes an \a item from the menu.
568*/
570{
571 if (!item || !m_items.removeOne(item))
572 return;
573
574 m_data.removeOne(item);
575 if (m_handle)
576 m_handle->removeMenuItem(item->handle());
577 item->setMenu(nullptr);
578 sync();
579 emit itemsChanged();
580}
581
582/*!
583 \qmlmethod void Qt.labs.platform::Menu::addMenu(Menu submenu)
584
585 Adds a \a submenu to the end of the menu.
586*/
588{
589 insertMenu(m_items.size(), menu);
590}
591
592/*!
593 \qmlmethod void Qt.labs.platform::Menu::insertMenu(int index, Menu submenu)
594
595 Inserts a \a submenu at the specified \a index in the menu.
596*/
598{
599 if (!menu)
600 return;
601
602 menu->setParentMenu(this);
603 insertItem(index, menu->menuItem());
604}
605
606/*!
607 \qmlmethod void Qt.labs.platform::Menu::removeMenu(Menu submenu)
608
609 Removes a \a submenu from the menu.
610*/
612{
613 if (!menu)
614 return;
615
616 menu->setParentMenu(nullptr);
617 removeItem(menu->menuItem());
618}
619
620/*!
621 \qmlmethod void Qt.labs.platform::Menu::clear()
622
623 Removes all items from the menu.
624*/
626{
627 if (m_items.isEmpty())
628 return;
629
630 for (QQuickLabsPlatformMenuItem *item : std::as_const(m_items)) {
631 m_data.removeOne(item);
632 if (m_handle)
633 m_handle->removeMenuItem(item->handle());
634 item->setMenu(nullptr);
635 delete item;
636 }
637
638 m_items.clear();
639 sync();
640 emit itemsChanged();
641}
642
643/*!
644 \qmlmethod void Qt.labs.platform::Menu::open(MenuItem item)
645
646 Opens the menu at the current mouse position, optionally aligned to a menu \a item.
647*/
648
649/*!
650 \qmlmethod void Qt.labs.platform::Menu::open(Item target, MenuItem item)
651
652 Opens the menu at the specified \a target item, optionally aligned to a menu \a item.
653*/
654void QQuickLabsPlatformMenu::open(QQmlV4FunctionPtr args)
655{
656 if (!m_handle)
657 return;
658
659 if (args->length() > 2) {
660 args->v4engine()->throwTypeError();
661 return;
662 }
663
664 QV4::ExecutionEngine *v4 = args->v4engine();
665 QV4::Scope scope(v4);
666
667 QQuickItem *targetItem = nullptr;
668 if (args->length() > 0) {
669 QV4::ScopedValue value(scope, (*args)[0]);
670 QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
671 if (object)
672 targetItem = qobject_cast<QQuickItem *>(object->object());
673 }
674
675 QQuickLabsPlatformMenuItem *menuItem = nullptr;
676 if (args->length() > 1) {
677 QV4::ScopedValue value(scope, (*args)[1]);
678 QV4::Scoped<QV4::QObjectWrapper> object(scope, value->as<QV4::QObjectWrapper>());
679 if (object)
680 menuItem = qobject_cast<QQuickLabsPlatformMenuItem *>(object->object());
681 }
682
683 QPoint offset;
684 QWindow *window = findWindow(targetItem, &offset);
685
686 QRect targetRect;
687 if (targetItem) {
688 QRectF sceneBounds = targetItem->mapRectToScene(targetItem->boundingRect());
689 targetRect = sceneBounds.toAlignedRect().translated(offset);
690 } else {
691#if QT_CONFIG(cursor)
692 QPoint pos = QCursor::pos();
693 if (window)
694 pos = window->mapFromGlobal(pos);
695 targetRect.moveTo(pos);
696#endif
697 }
698 m_handle->showPopup(window,
699 QHighDpi::toNativeLocalPosition(targetRect, window),
700 menuItem ? menuItem->handle() : nullptr);
701}
702
703/*!
704 \qmlmethod void Qt.labs.platform::Menu::close()
705
706 Closes the menu.
707*/
709{
710 if (m_handle)
711 m_handle->dismiss();
712}
713
717
719{
720 m_complete = true;
721 if (m_handle && m_iconLoader)
722 m_iconLoader->setEnabled(true);
723 sync();
724}
725
727{
728 if (!m_iconLoader) {
729 QQuickLabsPlatformMenu *that = const_cast<QQuickLabsPlatformMenu *>(this);
730 static int slot = staticMetaObject.indexOfSlot("updateIcon()");
731 m_iconLoader = new QQuickLabsPlatformIconLoader(slot, that);
732 m_iconLoader->setEnabled(m_complete);
733 }
734 return m_iconLoader;
735}
736
737static QWindow *effectiveWindow(QWindow *window, QPoint *offset)
738{
739 QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window);
740 if (quickWindow) {
741 QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, offset);
742 if (renderWindow)
743 return renderWindow;
744 }
745 return window;
746}
747
748QWindow *QQuickLabsPlatformMenu::findWindow(QQuickItem *target, QPoint *offset) const
749{
750 if (target)
751 return effectiveWindow(target->window(), offset);
752
753 if (m_menuBar && m_menuBar->window())
754 return effectiveWindow(m_menuBar->window(), offset);
755
756 QObject *obj = parent();
757 while (obj) {
758 QWindow *window = qobject_cast<QWindow *>(obj);
759 if (window)
760 return effectiveWindow(window, offset);
761
762 QQuickItem *item = qobject_cast<QQuickItem *>(obj);
763 if (item && item->window())
764 return effectiveWindow(item->window(), offset);
765
766 obj = obj->parent();
767 }
768 return nullptr;
769}
770
771void QQuickLabsPlatformMenu::data_append(QQmlListProperty<QObject> *property, QObject *object)
772{
773 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
774 if (QQuickLabsPlatformMenuItem *item = qobject_cast<QQuickLabsPlatformMenuItem *>(object))
775 menu->addItem(item);
776 else if (QQuickLabsPlatformMenu *subMenu = qobject_cast<QQuickLabsPlatformMenu *>(object))
777 menu->addMenu(subMenu);
778 else
779 menu->m_data.append(object);
780}
781
782qsizetype QQuickLabsPlatformMenu::data_count(QQmlListProperty<QObject> *property)
783{
784 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
785 return menu->m_data.size();
786}
787
788QObject *QQuickLabsPlatformMenu::data_at(QQmlListProperty<QObject> *property, qsizetype index)
789{
790 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
791 return menu->m_data.value(index);
792}
793
794void QQuickLabsPlatformMenu::data_clear(QQmlListProperty<QObject> *property)
795{
796 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
797 menu->m_data.clear();
798}
799
800void QQuickLabsPlatformMenu::items_append(QQmlListProperty<QQuickLabsPlatformMenuItem> *property, QQuickLabsPlatformMenuItem *item)
801{
802 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
803 menu->addItem(item);
804}
805
806qsizetype QQuickLabsPlatformMenu::items_count(QQmlListProperty<QQuickLabsPlatformMenuItem> *property)
807{
808 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
809 return menu->m_items.size();
810}
811
812QQuickLabsPlatformMenuItem *QQuickLabsPlatformMenu::items_at(QQmlListProperty<QQuickLabsPlatformMenuItem> *property, qsizetype index)
813{
814 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
815 return menu->m_items.value(index);
816}
817
818void QQuickLabsPlatformMenu::items_clear(QQmlListProperty<QQuickLabsPlatformMenuItem> *property)
819{
820 QQuickLabsPlatformMenu *menu = static_cast<QQuickLabsPlatformMenu *>(property->object);
821 menu->clear();
822}
823
824void QQuickLabsPlatformMenu::updateIcon()
825{
826 if (!m_handle || !m_iconLoader)
827 return;
828
829 m_handle->setIcon(m_iconLoader->toQIcon());
830 sync();
831}
832
833QT_END_NAMESPACE
834
835#include "moc_qquicklabsplatformmenu_p.cpp"
void setIcon(const QQuickLabsPlatformIcon &icon)
QQuickLabsPlatformIcon icon() const
bool operator==(const QQuickLabsPlatformIcon &other) const
QPlatformMenuBar * handle() const
void setIcon(const QQuickLabsPlatformIcon &icon)
void setMenu(QQuickLabsPlatformMenu *menu)
void setSubMenu(QQuickLabsPlatformMenu *menu)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QQuickLabsPlatformMenuBar * menuBar() const
\readonly \qmlproperty MenuBar Qt.labs.platform::Menu::menuBar
bool isVisible() const
\qmlproperty bool Qt.labs.platform::Menu::visible
Q_INVOKABLE void insertItem(int index, QQuickLabsPlatformMenuItem *item)
\qmlmethod void Qt.labs.platform::Menu::insertItem(int index, MenuItem item)
QFont font() const
\qmlproperty font Qt.labs.platform::Menu::font
QString title() const
\qmlproperty string Qt.labs.platform::Menu::title
Q_INVOKABLE void removeMenu(QQuickLabsPlatformMenu *menu)
\qmlmethod void Qt.labs.platform::Menu::removeMenu(Menu submenu)
QQuickLabsPlatformIcon icon() const
QQuickLabsPlatformIconLoader * iconLoader() const
QQuickLabsPlatformMenu * parentMenu() const
\readonly \qmlproperty Menu Qt.labs.platform::Menu::parentMenu
Q_INVOKABLE void addMenu(QQuickLabsPlatformMenu *menu)
\qmlmethod void Qt.labs.platform::Menu::addMenu(Menu submenu)
Q_INVOKABLE void removeItem(QQuickLabsPlatformMenuItem *item)
\qmlmethod void Qt.labs.platform::Menu::removeItem(MenuItem item)
void setIcon(const QQuickLabsPlatformIcon &icon)
Q_INVOKABLE void clear()
\qmlmethod void Qt.labs.platform::Menu::clear()
void setFont(const QFont &font)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
Q_INVOKABLE void addItem(QQuickLabsPlatformMenuItem *item)
\qmlmethod void Qt.labs.platform::Menu::addItem(MenuItem item)
QQmlListProperty< QObject > data()
Q_INVOKABLE void insertMenu(int index, QQuickLabsPlatformMenu *menu)
\qmlmethod void Qt.labs.platform::Menu::insertMenu(int index, Menu submenu)
int minimumWidth() const
\qmlproperty int Qt.labs.platform::Menu::minimumWidth
QPlatformMenu::MenuType type() const
\qmlproperty enumeration Qt.labs.platform::Menu::type
QQuickLabsPlatformMenuItem * menuItem() const
\readonly \qmlproperty MenuItem Qt.labs.platform::Menu::menuItem
QQmlListProperty< QQuickLabsPlatformMenuItem > items()
QPlatformMenu * handle() const
void close()
\qmlmethod void Qt.labs.platform::Menu::close()
bool isEnabled() const
\qmlproperty bool Qt.labs.platform::Menu::enabled
void classBegin() override
Invoked after class creation, but before any properties have been set.
void setMenuBar(QQuickLabsPlatformMenuBar *menuBar)
void setTitle(const QString &title)
void setParentMenu(QQuickLabsPlatformMenu *menu)
QWindow * findWindow(QQuickItem *target, QPoint *offset) const
static QWindow * effectiveWindow(QWindow *window, QPoint *offset)