QToolButton设置弹出菜单
2009-01-15 17:03
169 查看
QToolButton设置弹出菜单
QToolButton *toolButton= new QToolButton;
QMenu *menu=new QMenu();
menu->addMenu(tr("0"));
menu->addMenu(tr("1"));
menu->addMenu(tr("3"));
toolButton->setIcon( QPixmap( "images//photo1.png" ) );
toolButton->setIconSize( QPixmap( "images//photo1.png").size() );
toolButton->setToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton->setPopupMode(QToolButton::InstantPopup );
toolButton->setMenu(menu);
弹出菜单的弹出方式有以下几种模式参考(参考Qt4.1.0参考文档):
ToolButtonPopupMode
Describes how a menu should be popped up for tool buttons that has a menu set or contains a list of actions.
QToolButton *toolButton= new QToolButton;
QMenu *menu=new QMenu();
menu->addMenu(tr("0"));
menu->addMenu(tr("1"));
menu->addMenu(tr("3"));
toolButton->setIcon( QPixmap( "images//photo1.png" ) );
toolButton->setIconSize( QPixmap( "images//photo1.png").size() );
toolButton->setToolButtonStyle( Qt::ToolButtonTextUnderIcon);
toolButton->setPopupMode(QToolButton::InstantPopup );
toolButton->setMenu(menu);
弹出菜单的弹出方式有以下几种模式参考(参考Qt4.1.0参考文档):
ToolButtonPopupMode
Describes how a menu should be popped up for tool buttons that has a menu set or contains a list of actions.
Constant | Value | Description |
---|---|---|
QToolButton::DelayedPopup | 0 | After pressing and holding the tool button down for a certain amount of time (the timeout is style dependant, see QStyle::SH_ToolButton_PopupDelay), the menu is displayed. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user presses and holds the button down for a while, the tool button shows a menu containing the current history list |
QToolButton::MenuButtonPopup | 1 | In this mode the tool button displays a special arrow to indicate that a menu is present. The menu is displayed when the arrow part of the button is pressed. |
QToolButton::InstantPopup | 2 | The menu is displayed, without delay, when the tool button is pressed. In this mode, the button's own action is not triggered. |
相关文章推荐
- QToolButton设置弹出菜单
- QToolButton设置弹出菜单
- [Flex] PopUpButton系列 —— 设置弹出菜单与主按钮之间的间隔
- Android 通过按钮弹出系统菜单(通过Button显示菜单)转
- 设置底部弹出菜单
- QT的一个奇怪问题,设置了Qt::Tool后,点击弹出对话框的确定取消按钮,程序直接退出。
- Android的Toolbar(含溢出菜单设置[弹出菜单的使用])的使用PopMenu的样式
- 设置右上角的菜单button
- 设置toolbar中弹出的menu菜单在toolbar的底部(下面)显示
- Android的Toolbar(含溢出菜单设置[弹出菜单的使用])的使用PopMenu的样式
- Flex创建弹出菜单(PopUpButton/Menu/PopMenuButton)
- C# Winform鼠标左键点击按钮弹出设置菜单
- C# ToolStrip菜单图标大小设置 源码下载
- 一个WinForm记事本程序(包含主/下拉/弹出菜单/打开文件/保存文件/打印/页面设置/字体/颜色对话框/剪切版操作等等控件用法以及记事本菜单事件/按键事件的具体代码)
- Winform鼠标左键点击按钮弹出设置菜单
- 在button 事件中 弹出menu 菜单
- Toolbar 设置 menu 背景色、字体颜色以及弹出菜单不悬浮
- [Flex] PopUpButton系列 —— 弹出菜单的行高设置
- Android 通过按钮弹出菜单(通过Button显示菜单)
- 一个WinForm记事本程序(包含主/下拉/弹出菜单/打开文件/保存文件/打印/页面设置/字体/颜色对话框/剪切版操作等等控件用法以及记事本菜单事件/按键事件的具体代码)