IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

MenuItem QML Type

MenuItem provides an item to add in a menu or a menu bar.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

MenuItem QML Type

Detailed Description

Image non disponible
 
Sélectionnez
Menu {
    text: "Edit"

    MenuItem {
        text: "Cut"
        shortcut: "Ctrl+X"
        onTriggered: ...
    }

    MenuItem {
        text: "Copy"
        shortcut: "Ctrl+C"
        onTriggered: ...
    }

    MenuItem {
        text: "Paste"
        shortcut: "Ctrl+V"
        onTriggered: ...
    }
}

See Also

Property Documentation

 

action : Action

The action bound to this menu item. It will provide values for all the properties of the menu item. However, it is possible to override the action's text, iconSource, and iconName properties by just assigning these properties, allowing some customization.

In addition, the menu item triggered() and toggled() signals will not be emitted. Instead, the action triggered() and toggled() signals will be.

Defaults to null, meaning no action is bound to the menu item.

checkable : bool

Whether the menu item can be checked, or toggled. Defaults to false.

See Also

See also checked

checked : bool

If the menu item is checkable, this property reflects its checked state. Defaults to false.

See Also

enabled : bool

Whether the menu item is enabled, and responsive to user interaction. Defaults to true.

exclusiveGroup : ExclusiveGroup

If a menu item is checkable, an ExclusiveGroup can be attached to it. All the menu items sharing the same exclusive group, and by extension, any Action sharing it, become mutually exclusive selectable, meaning that only the last checked menu item will actually be checked.

Defaults to null, meaning no exclusive behavior is to be expected.

See Also

See also checked, checkable

iconName : string

Sets the icon name for the MenuItem icon. This will pick the icon with the given name from the current theme. Overrides the item's bound action iconName property. Defaults to an empty string.

This property requires QApplication.

See Also

iconSource : url

Sets the icon file or resource url for the MenuItem icon. Overrides the item's bound action iconSource property. Defaults to an empty URL.

See Also

shortcut : keysequence

Shortcut bound to the menu item. The keysequence can be a string or a standard key.

Defaults to an empty string.

 
Sélectionnez
MenuItem {
    id: copyItem
    text: qsTr("&Copy")
    shortcut: StandardKey.Copy
}
See Also

See also Action::shortcut

text : string

Text for the menu item. Overrides the item's bound action text property.

Mnemonics are supported by prefixing the shortcut letter with &. For instance, "\&Open" will bind the Alt-O shortcut to the "Open" menu item. Note that not all platforms support mnemonics.

Defaults to an empty string.

See Also

See also Action::text

[read-only] type : enumeration

This property is read-only and constant, and its value is MenuItemType.Item.

visible : bool

Whether the menu item should be visible. Defaults to true.

Signal Documentation

 

toggled(checked)

Emitted whenever a menu item's checked property changes. This usually happens at the same time as triggered.

The corresponding handler is onToggled.

The corresponding handler is onToggled.

See Also

triggered()

Emitted when either the menu item or its bound action have been activated.

The corresponding handler is onTriggered.

The corresponding handler is onTriggered.

See Also

Method Documentation

 

void trigger()

Manually trigger a menu item. Will also trigger the item's bound action.

See Also

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+