Wiki Markup |
---|
{alias:qmenu} |
Name
qmenu — pulldown or right-click menu
...
The qmenu command creates a QMenu object. The command may take an optional title argument. A QMenu object may appear as a pulldown menu, a rightclick menu, or a submenu. Menus may be attached to actions, menubars, toolbuttons, other menus, or set as right-click menus in QTreeWidget objects. The QMenu becomes the current widget.
Arguments
_title
The text at the point where the menu is attached. If the menu is a pulldown menu along a menubar, the text will appear in the menubar. If the menu is a submenu, the text will appear at the point in the parent menu where the submenu is attached. The argument should be omitted when creating a right-click menu.
Examples
Ex.1: QMenu
Anchor | ||||
---|---|---|---|---|
|
No Format | ||||
---|---|---|---|---|
| ||||
# Create QMainWindow with built-in menubar
set w [qmainwindow]
qsetwindowtitle QMenu
# Get menubar from mainwindow
set menubar [qmenubar $w]
# Create 'File' action and add to menubar
set fileaction [qaction File]
qaddaction $menubar $fileaction
# Create pulldown menu and add to file action
set menu [qmenu]
qsetmenu $fileaction $menu
# Populate file menu
set openaction [qaction Open qopenfilename]
qaddaction $menu $openaction
qshow $w
|
...
Example QMenu shows a QMainWindow with a 'File' pulldown menu.
See qtoolbar for information on how to attach a pulldown menu to a toolbutton.