diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-22 08:44:34 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-22 08:55:29 +0200 |
commit | ab91c57135f7a86437a5a4341cd32df1d4682480 (patch) | |
tree | 713612fe2c27ff43ab4a3d5ed3b363c6141d5fbf /src/quicktemplates2/qquickmenu.cpp | |
parent | c5a44092c8b73c540862c4a160c31487a8518992 (diff) | |
parent | 7193318330bc518255fb7ed008c144578f49b4bd (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Change-Id: I37aab846346692fd4bff08b0dbab66db3a8e2716
Diffstat (limited to 'src/quicktemplates2/qquickmenu.cpp')
-rw-r--r-- | src/quicktemplates2/qquickmenu.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index b8522668..bf37f801 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -89,6 +89,15 @@ QT_BEGIN_NAMESPACE } \endcode + Typically, menu items are statically declared as children of the menu, but + Menu also provides API to \l {addItem}{add}, \l {insertItem}{insert}, + \l {moveItem}{move} and \l {removeItem}{remove} items dynamically. The + items in a menu can be accessed using \l itemAt() or + \l {Popup::}{contentChildren}. + + Although \l {MenuItem}{MenuItems} are most commonly used with Menu, it can + contain any type of item. + \sa {Customizing Menu}, {Menu Controls}, {Popup Controls} */ @@ -350,7 +359,7 @@ void QQuickMenu::moveItem(int from, int to) /*! \qmlmethod void QtQuick.Controls::Menu::removeItem(int index) - Removes an item at \a index. + Removes the item at \a index. \note The ownership of the item is transferred to the caller. */ @@ -372,8 +381,20 @@ void QQuickMenu::removeItem(int index) This property holds the model used to display menu items. - By default, the model is an \l ObjectModel, in order to allow declaring - menu items as children of the menu. + The content model is provided for visualization purposes. It can be assigned + as a model to a content item that presents the contents of the menu. + + \code + Menu { + id: menu + contentItem: ListView { + model: menu.contentModel + } + } + \endcode + + The model allows menu items to be statically declared as children of the + menu. */ QVariant QQuickMenu::contentModel() const { @@ -387,7 +408,14 @@ QVariant QQuickMenu::contentModel() const This property holds the list of content data. - \sa Item::data + The list contains all objects that have been declared in QML as children + of the menu, and also items that have been dynamically added or + inserted using the \l addItem() and \l insertItem() methods, respectively. + + \note Unlike \c contentChildren, \c contentData does include non-visual QML + objects. It is not re-ordered when items are inserted or moved. + + \sa Item::data, contentChildren */ QQmlListProperty<QObject> QQuickMenu::contentData() { @@ -402,9 +430,11 @@ QQmlListProperty<QObject> QQuickMenu::contentData() /*! \qmlproperty string QtQuick.Controls::Menu::title - Title for the menu as a submenu or in a menubar. + This property holds the title for the menu. - Its value defaults to an empty string. + The title of a menu is often displayed in the text of a menu item when the + menu is a submenu, and in the text of a tool button when it is in a + menubar. */ QString QQuickMenu::title() const { |