OptionPushButton Class

class Utils::OptionPushButton

The OptionPushButton class implements a QPushButton for which the menu is only opened if the user presses the menu indicator. More...

Header: #include <OptionPushButton>
Inherits: QPushButton

Public Functions

OptionPushButton(QWidget *parent = nullptr)
OptionPushButton(const QString &text, QWidget *parent = nullptr)
void setOptionalMenu(QMenu *menu)

Detailed Description

Use OptionPushButton::setOptionalMenu() to set the menu and its actions. If the users clicks on the menu indicator of the push button, this menu is opened, and its actions are triggered when the user selects them.

If the user clicks anywhere else on the button, the QAbstractButton::clicked() signal is sent, as if the button didn't have a menu.

Note: You may not call QPushButton::setMenu(). Use OptionPushButton::setOptionalMenu() instead.

Member Function Documentation

OptionPushButton::OptionPushButton(QWidget *parent = nullptr)

Constructs an option push button with parent parent.

OptionPushButton::OptionPushButton(const QString &text, QWidget *parent = nullptr)

Constructs an option push button with text text and parent parent.

void OptionPushButton::setOptionalMenu(QMenu *menu)

Associates the popup menu menu with this push button. This menu is shown if the user clicks on the menu indicator that is shown. If the user clicks anywhere else on the button, QAbstractButton::clicked() is sent instead.

Note: Calling this method removes all connections to the QAbstractButton::pressed() signal.

Ownership of the menu is not transferred to the push button.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.