zoukankan      html  css  js  c++  java
  • QToolButton弹出菜单

    QToolButton弹出菜单

     1 QToolButton *toolButton= new QToolButton;
     2 QMenu *menu = new QMenu();
     3 menu->addMenu(tr("菜单1"));
     4 menu->addMenu(tr("菜单2"));
     5 menu->addMenu(tr("菜单3"));
     6 toolButton->setIcon(QPixmap("images//menupic.png"));
     7 toolButton->setIconSize(QPixmap( "images//menupic.png").size());
     8 toolButton->setToolButtonStyle( Qt::ToolButtonTextUnderIcon);
     9 toolButton->setPopupMode(QToolButton::InstantPopup );
    10 toolButton->setMenu(menu);

    弹出菜单的弹出方式有3种:

    Constant Value Description
    QToolButton::DelayedPopup 0 After pressing and holding the tool button down for a certain amount of time (the timeout is style dependent, 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.
  • 相关阅读:
    Windbg学习 (0x0002) 命令基础
    Windbg学习 (0x0001) 安装与基本配置
    python 20day--装饰器详解
    python 19day--生成器详解
    python 18day--迭代器详解
    python 17day--内置函数
    python 16day--函数作用域与函数式编程
    python 15day--递归函数与匿名函数
    python 14day--函数
    python 13day--集合、字符串格式化
  • 原文地址:https://www.cnblogs.com/IAMSailorMoon/p/15147546.html
Copyright © 2011-2022 走看看