- Extending Qt Creator Manual
- QtCreator
- OptionPushButton
- Extending Qt Creator Manual 13.0.0

# 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>

- List of all members, including inherited members

## Public Functions

| OptionPushButton(const QString &text, QWidget *parent = nullptr)
| OptionPushButton(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(const QString &text, QWidget *parent = nullptr)

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

### OptionPushButton::OptionPushButton(QWidget *parent = nullptr)

Constructs an option push button with 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.