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.
  • 相关阅读:
    Objective-C多线程-02
    Objective-C多线程-01
    Objective-C的属性与实例变量
    KVO的内部实现原理
    ASIHTTPRequest 和 AFNetWorking 的比较
    Python类和函数_规划式开发
    禁用密码登录,改用key秘钥对登录
    Python类和函数_时间与纯函数
    Python类和对象_调试与术语
    Python类和对象_修改和复制
  • 原文地址:https://www.cnblogs.com/IAMSailorMoon/p/15147546.html
Copyright © 2011-2022 走看看