[][src]Struct qt_widgets::QPushButton

#[repr(C)]pub struct QPushButton { /* fields omitted */ }

The QPushButton widget provides a command button.

C++ class: QPushButton.

C++ documentation:

The QPushButton widget provides a command button.

[Missing image windows-pushbutton.jpg]

The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.

A command button is rectangular and typically displays a text label describing its action. A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:

QPushButton *button = new QPushButton("&Download", this);

In this example the shortcut is Alt+D. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

Push buttons display a textual label, and optionally a small icon. These can be set using the constructors and changed later using setText() and setIcon(). If the button is disabled, the appearance of the text and icon will be manipulated with respect to the GUI style to make the button look "disabled".

A push button emits the signal clicked() when it is activated by the mouse, the Spacebar or by a keyboard shortcut. Connect to this signal to perform the button's action. Push buttons also provide less commonly used signals, for example pressed() and released().

Command buttons in dialogs are by default auto-default buttons, i.e., they become the default push button automatically when they receive the keyboard input focus. A default button is a push button that is activated when the user presses the Enter or Return key in a dialog. You can change this with setAutoDefault(). Note that auto-default buttons reserve a little extra space which is necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault(false).

Being so central, the button widget has grown to accommodate a great many variations in the past decade. The Microsoft style guide now shows about ten different states of Windows push buttons and the text implies that there are dozens more when all the combinations of features are taken into consideration.

The most important modes or states are:

  • Available or not (grayed out, disabled).
  • Standard push button, toggling push button or menu button.
  • On or off (only for toggling push buttons).
  • Default or normal. The default button in a dialog can generally be "clicked" using the Enter or Return key.
  • Auto-repeat or not.
  • Pressed down or not.

As a general rule, use a push button when the application or dialog window performs an action when the user clicks on it (such as Apply, Cancel, Close and Help) and when the widget is supposed to have a wide, rectangular shape with a text label. Small, typically square buttons that change the state of the window rather than performing an action (such as the buttons in the top-right corner of the QFileDialog) are not command buttons, but tool buttons. Qt provides a special class (QToolButton) for these buttons.

If you need toggle behavior (see setCheckable()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scroll bar (see setAutoRepeat()), a command button is probably not what you want. When in doubt, use a tool button.

Note: On macOS when a push button's width becomes smaller than 50 or its height becomes smaller than 30, the button's corners are changed from round to square. Use the setMinimumSize() function to prevent this behavior.

A variation of a command button is a menu button. These provide not just one command, but several, since when they are clicked they pop up a menu of options. Use the method setMenu() to associate a popup menu with a push button.

Other classes of buttons are option buttons (see QRadioButton) and check boxes (see QCheckBox).

In Qt, the QAbstractButton base class provides most of the modes and other API, and QPushButton provides GUI logic. See QAbstractButton for more information about the API.

Methods

impl QPushButton[src]

pub fn slot_show_menu(&self) -> Receiver<()>[src]

Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.

Returns a built-in Qt slot QPushButton::showMenu that can be passed to qt_core::Signal::connect.

C++ documentation:

Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.

pub unsafe fn auto_default(&self) -> bool[src]

This property holds whether the push button is an auto default button

Calls C++ function: bool QPushButton::autoDefault() const.

C++ documentation:

This property holds whether the push button is an auto default button

If this property is set to true then the push button is an auto default button.

In some GUI styles a default button is drawn with an extra frame around it, up to 3 pixels or more. Qt automatically keeps this space free around auto-default buttons, i.e., auto-default buttons may have a slightly larger size hint.

This property's default is true for buttons that have a QDialog parent; otherwise it defaults to false.

See the default property for details of how default and auto-default interact.

Access functions:

bool autoDefault() const
void setAutoDefault(bool)

pub unsafe fn is_default(&self) -> bool[src]

This property holds whether the push button is the default button

Calls C++ function: bool QPushButton::isDefault() const.

C++ documentation:

This property holds whether the push button is the default button

Default and autodefault buttons decide what happens when the user presses enter in a dialog.

A button with this property set to true (i.e., the dialog's default button,) will automatically be pressed when the user presses enter, with one exception: if an autoDefault button currently has focus, the autoDefault button is pressed. When the dialog has autoDefault buttons but no default button, pressing enter will press either the autoDefault button that currently has focus, or if no button has focus, the next autoDefault button in the focus chain.

In a dialog, only one push button at a time can be the default button. This button is then displayed with an additional frame (depending on the GUI style).

The default button behavior is provided only in dialogs. Buttons can always be clicked from the keyboard by pressing Spacebar when the button has focus.

If the default property is set to false on the current default button while the dialog is visible, a new default will automatically be assigned the next time a push button in the dialog receives focus.

This property's default is false.

Access functions:

bool isDefault() const
void setDefault(bool)

pub unsafe fn is_flat(&self) -> bool[src]

This property holds whether the button border is raised

Calls C++ function: bool QPushButton::isFlat() const.

C++ documentation:

This property holds whether the button border is raised

This property's default is false. If this property is set, most styles will not paint the button background unless the button is being pressed. setAutoFillBackground() can be used to ensure that the background is filled using the QPalette::Button brush.

Access functions:

bool isFlat() const
void setFlat(bool)

pub unsafe fn menu(&self) -> QPtr<QMenu>[src]

Returns the button's associated popup menu or 0 if no popup menu has been set.

Calls C++ function: QMenu* QPushButton::menu() const.

C++ documentation:

Returns the button's associated popup menu or 0 if no popup menu has been set.

See also setMenu().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QPushButton::metaObject() const.

pub unsafe fn minimum_size_hint(&self) -> CppBox<QSize>[src]

Reimplemented from QWidget::minimumSizeHint().

Calls C++ function: virtual QSize QPushButton::minimumSizeHint() const.

C++ documentation:

Reimplemented from QWidget::minimumSizeHint().

pub unsafe fn from_q_widget(
    parent: impl CastInto<Ptr<QWidget>>
) -> QBox<QPushButton>
[src]

Constructs a push button with no text and a parent.

Calls C++ function: [constructor] void QPushButton::QPushButton(QWidget* parent = …).

C++ documentation:

Constructs a push button with no text and a parent.

pub unsafe fn from_q_string_q_widget(
    text: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QWidget>>
) -> QBox<QPushButton>
[src]

Constructs a push button with the parent parent and the text text.

Calls C++ function: [constructor] void QPushButton::QPushButton(const QString& text, QWidget* parent = …).

C++ documentation:

Constructs a push button with the parent parent and the text text.

pub unsafe fn from_q_icon_q_string_q_widget(
    icon: impl CastInto<Ref<QIcon>>,
    text: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QWidget>>
) -> QBox<QPushButton>
[src]

Constructs a push button with an icon and a text, and a parent.

Calls C++ function: [constructor] void QPushButton::QPushButton(const QIcon& icon, const QString& text, QWidget* parent = …).

C++ documentation:

Constructs a push button with an icon and a text, and a parent.

Note that you can also pass a QPixmap object as an icon (thanks to the implicit type conversion provided by C++).

pub unsafe fn new() -> QBox<QPushButton>[src]

The QPushButton widget provides a command button.

Calls C++ function: [constructor] void QPushButton::QPushButton().

C++ documentation:

The QPushButton widget provides a command button.

[Missing image windows-pushbutton.jpg]

The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.

A command button is rectangular and typically displays a text label describing its action. A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:

QPushButton *button = new QPushButton("&Download", this);

In this example the shortcut is Alt+D. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

Push buttons display a textual label, and optionally a small icon. These can be set using the constructors and changed later using setText() and setIcon(). If the button is disabled, the appearance of the text and icon will be manipulated with respect to the GUI style to make the button look "disabled".

A push button emits the signal clicked() when it is activated by the mouse, the Spacebar or by a keyboard shortcut. Connect to this signal to perform the button's action. Push buttons also provide less commonly used signals, for example pressed() and released().

Command buttons in dialogs are by default auto-default buttons, i.e., they become the default push button automatically when they receive the keyboard input focus. A default button is a push button that is activated when the user presses the Enter or Return key in a dialog. You can change this with setAutoDefault(). Note that auto-default buttons reserve a little extra space which is necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault(false).

Being so central, the button widget has grown to accommodate a great many variations in the past decade. The Microsoft style guide now shows about ten different states of Windows push buttons and the text implies that there are dozens more when all the combinations of features are taken into consideration.

The most important modes or states are:

  • Available or not (grayed out, disabled).
  • Standard push button, toggling push button or menu button.
  • On or off (only for toggling push buttons).
  • Default or normal. The default button in a dialog can generally be "clicked" using the Enter or Return key.
  • Auto-repeat or not.
  • Pressed down or not.

As a general rule, use a push button when the application or dialog window performs an action when the user clicks on it (such as Apply, Cancel, Close and Help) and when the widget is supposed to have a wide, rectangular shape with a text label. Small, typically square buttons that change the state of the window rather than performing an action (such as the buttons in the top-right corner of the QFileDialog) are not command buttons, but tool buttons. Qt provides a special class (QToolButton) for these buttons.

If you need toggle behavior (see setCheckable()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scroll bar (see setAutoRepeat()), a command button is probably not what you want. When in doubt, use a tool button.

Note: On macOS when a push button's width becomes smaller than 50 or its height becomes smaller than 30, the button's corners are changed from round to square. Use the setMinimumSize() function to prevent this behavior.

A variation of a command button is a menu button. These provide not just one command, but several, since when they are clicked they pop up a menu of options. Use the method setMenu() to associate a popup menu with a push button.

Other classes of buttons are option buttons (see QRadioButton) and check boxes (see QCheckBox).

In Qt, the QAbstractButton base class provides most of the modes and other API, and QPushButton provides GUI logic. See QAbstractButton for more information about the API.

pub unsafe fn from_q_string(
    text: impl CastInto<Ref<QString>>
) -> QBox<QPushButton>
[src]

Constructs a push button with the parent parent and the text text.

Calls C++ function: [constructor] void QPushButton::QPushButton(const QString& text).

C++ documentation:

Constructs a push button with the parent parent and the text text.

pub unsafe fn from_q_icon_q_string(
    icon: impl CastInto<Ref<QIcon>>,
    text: impl CastInto<Ref<QString>>
) -> QBox<QPushButton>
[src]

Constructs a push button with an icon and a text, and a parent.

Calls C++ function: [constructor] void QPushButton::QPushButton(const QIcon& icon, const QString& text).

C++ documentation:

Constructs a push button with an icon and a text, and a parent.

Note that you can also pass a QPixmap object as an icon (thanks to the implicit type conversion provided by C++).

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QPushButton::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QPushButton::qt_metacast(const char* arg1).

pub unsafe fn set_auto_default(&self, arg1: bool)[src]

This property holds whether the push button is an auto default button

Calls C++ function: void QPushButton::setAutoDefault(bool arg1).

C++ documentation:

This property holds whether the push button is an auto default button

If this property is set to true then the push button is an auto default button.

In some GUI styles a default button is drawn with an extra frame around it, up to 3 pixels or more. Qt automatically keeps this space free around auto-default buttons, i.e., auto-default buttons may have a slightly larger size hint.

This property's default is true for buttons that have a QDialog parent; otherwise it defaults to false.

See the default property for details of how default and auto-default interact.

Access functions:

bool autoDefault() const
void setAutoDefault(bool)

pub unsafe fn set_default(&self, arg1: bool)[src]

This property holds whether the push button is the default button

Calls C++ function: void QPushButton::setDefault(bool arg1).

C++ documentation:

This property holds whether the push button is the default button

Default and autodefault buttons decide what happens when the user presses enter in a dialog.

A button with this property set to true (i.e., the dialog's default button,) will automatically be pressed when the user presses enter, with one exception: if an autoDefault button currently has focus, the autoDefault button is pressed. When the dialog has autoDefault buttons but no default button, pressing enter will press either the autoDefault button that currently has focus, or if no button has focus, the next autoDefault button in the focus chain.

In a dialog, only one push button at a time can be the default button. This button is then displayed with an additional frame (depending on the GUI style).

The default button behavior is provided only in dialogs. Buttons can always be clicked from the keyboard by pressing Spacebar when the button has focus.

If the default property is set to false on the current default button while the dialog is visible, a new default will automatically be assigned the next time a push button in the dialog receives focus.

This property's default is false.

Access functions:

bool isDefault() const
void setDefault(bool)

pub unsafe fn set_flat(&self, arg1: bool)[src]

This property holds whether the button border is raised

Calls C++ function: void QPushButton::setFlat(bool arg1).

C++ documentation:

This property holds whether the button border is raised

This property's default is false. If this property is set, most styles will not paint the button background unless the button is being pressed. setAutoFillBackground() can be used to ensure that the background is filled using the QPalette::Button brush.

Access functions:

bool isFlat() const
void setFlat(bool)

pub unsafe fn set_menu(&self, menu: impl CastInto<Ptr<QMenu>>)[src]

Associates the popup menu menu with this push button. This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text.

Calls C++ function: void QPushButton::setMenu(QMenu* menu).

C++ documentation:

Associates the popup menu menu with this push button. This turns the button into a menu button, which in some styles will produce a small triangle to the right of the button's text.

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

Screenshot of a Fusion style push button with popup menu.

A push button with popup menus shown in the Fusion widget style.

See also menu().

pub unsafe fn show_menu(&self)[src]

Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.

Calls C++ function: [slot] void QPushButton::showMenu().

C++ documentation:

Shows (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.

pub unsafe fn size_hint(&self) -> CppBox<QSize>[src]

Reimplemented from QWidget::sizeHint().

Calls C++ function: virtual QSize QPushButton::sizeHint() const.

C++ documentation:

Reimplemented from QWidget::sizeHint().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QPushButton::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QPushButton::trUtf8(const char* s, const char* c, int n).

Methods from Deref<Target = QAbstractButton>

pub fn slot_set_icon_size(&self) -> Receiver<(*const QSize,)>[src]

This property holds the icon size used for this button.

Returns a built-in Qt slot QAbstractButton::setIconSize that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds the icon size used for this button.

The default size is defined by the GUI style. This is a maximum size for the icons. Smaller icons will not be scaled up.

Access functions:

QSize iconSize() const
void setIconSize(const QSize &size)

pub fn slot_animate_click(&self) -> Receiver<(c_int,)>[src]

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Returns a built-in Qt slot QAbstractButton::animateClick that can be passed to qt_core::Signal::connect.

C++ documentation:

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Calling this function again before the button is released resets the release timer.

All signals associated with a click are emitted as appropriate.

This function does nothing if the button is disabled.

See also click().

pub fn slot_click(&self) -> Receiver<()>[src]

Performs a click.

Returns a built-in Qt slot QAbstractButton::click that can be passed to qt_core::Signal::connect.

C++ documentation:

Performs a click.

All the usual signals associated with a click are emitted as appropriate. If the button is checkable, the state of the button is toggled.

This function does nothing if the button is disabled.

See also animateClick().

pub fn slot_toggle(&self) -> Receiver<()>[src]

Toggles the state of a checkable button.

Returns a built-in Qt slot QAbstractButton::toggle that can be passed to qt_core::Signal::connect.

C++ documentation:

Toggles the state of a checkable button.

See also checked.

pub fn slot_set_checked(&self) -> Receiver<(bool,)>[src]

This property holds whether the button is checked

Returns a built-in Qt slot QAbstractButton::setChecked that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds whether the button is checked

Only checkable buttons can be checked. By default, the button is unchecked.

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub fn pressed(&self) -> Signal<()>[src]

This signal is emitted when the button is pressed down.

Returns a built-in Qt signal QAbstractButton::pressed that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when the button is pressed down.

See also released() and clicked().

pub fn released(&self) -> Signal<()>[src]

This signal is emitted when the button is released.

Returns a built-in Qt signal QAbstractButton::released that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when the button is released.

See also pressed(), clicked(), and toggled().

pub fn clicked(&self) -> Signal<(bool,)>[src]

This signal is emitted when the button is activated (i.e., pressed down then released while the mouse cursor is inside the button), when the shortcut key is typed, or when click() or animateClick() is called. Notably, this signal is not emitted if you call setDown(), setChecked() or toggle().

Returns a built-in Qt signal QAbstractButton::clicked that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when the button is activated (i.e., pressed down then released while the mouse cursor is inside the button), when the shortcut key is typed, or when click() or animateClick() is called. Notably, this signal is not emitted if you call setDown(), setChecked() or toggle().

If the button is checkable, checked is true if the button is checked, or false if the button is unchecked.

See also pressed(), released(), and toggled().

pub fn toggled(&self) -> Signal<(bool,)>[src]

This signal is emitted whenever a checkable button changes its state. checked is true if the button is checked, or false if the button is unchecked.

Returns a built-in Qt signal QAbstractButton::toggled that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever a checkable button changes its state. checked is true if the button is checked, or false if the button is unchecked.

This may be the result of a user action, click() slot activation, or because setChecked() is called.

The states of buttons in exclusive button groups are updated before this signal is emitted. This means that slots can act on either the "off" signal or the "on" signal emitted by the buttons in the group whose states have changed.

For example, a slot that reacts to signals emitted by newly checked buttons but which ignores signals from buttons that have been unchecked can be implemented using the following pattern:

void MyWidget::reactToToggle(bool checked) { if (checked) { // Examine the new button states. ... } }

Button groups can be created using the QButtonGroup class, and updates to the button states monitored with the QButtonGroup::buttonClicked() signal.

Note: Notifier signal for property checked.

See also checked and clicked().

pub unsafe fn animate_click_1a(&self, msec: c_int)[src]

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Calls C++ function: [slot] void QAbstractButton::animateClick(int msec = …).

C++ documentation:

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Calling this function again before the button is released resets the release timer.

All signals associated with a click are emitted as appropriate.

This function does nothing if the button is disabled.

See also click().

pub unsafe fn animate_click_0a(&self)[src]

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Calls C++ function: [slot] void QAbstractButton::animateClick().

C++ documentation:

Performs an animated click: the button is pressed immediately, and released msec milliseconds later (the default is 100 ms).

Calling this function again before the button is released resets the release timer.

All signals associated with a click are emitted as appropriate.

This function does nothing if the button is disabled.

See also click().

pub unsafe fn auto_exclusive(&self) -> bool[src]

This property holds whether auto-exclusivity is enabled

Calls C++ function: bool QAbstractButton::autoExclusive() const.

C++ documentation:

This property holds whether auto-exclusivity is enabled

If auto-exclusivity is enabled, checkable buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. In an exclusive button group, only one button can be checked at any time; checking another button automatically unchecks the previously checked one.

The property has no effect on buttons that belong to a button group.

autoExclusive is off by default, except for radio buttons.

Access functions:

bool autoExclusive() const
void setAutoExclusive(bool)

See also QRadioButton.

pub unsafe fn auto_repeat(&self) -> bool[src]

This property holds whether autoRepeat is enabled

Calls C++ function: bool QAbstractButton::autoRepeat() const.

C++ documentation:

This property holds whether autoRepeat is enabled

If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.

Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.

Access functions:

bool autoRepeat() const
void setAutoRepeat(bool)

pub unsafe fn auto_repeat_delay(&self) -> c_int[src]

This property holds the initial delay of auto-repetition

Calls C++ function: int QAbstractButton::autoRepeatDelay() const.

C++ documentation:

This property holds the initial delay of auto-repetition

If autoRepeat is enabled, then autoRepeatDelay defines the initial delay in milliseconds before auto-repetition kicks in.

This property was introduced in Qt 4.2.

Access functions:

int autoRepeatDelay() const
void setAutoRepeatDelay(int)

See also autoRepeat and autoRepeatInterval.

pub unsafe fn auto_repeat_interval(&self) -> c_int[src]

This property holds the interval of auto-repetition

Calls C++ function: int QAbstractButton::autoRepeatInterval() const.

C++ documentation:

This property holds the interval of auto-repetition

If autoRepeat is enabled, then autoRepeatInterval defines the length of the auto-repetition interval in millisecons.

This property was introduced in Qt 4.2.

Access functions:

int autoRepeatInterval() const
void setAutoRepeatInterval(int)

See also autoRepeat and autoRepeatDelay.

pub unsafe fn click(&self)[src]

Performs a click.

Calls C++ function: [slot] void QAbstractButton::click().

C++ documentation:

Performs a click.

All the usual signals associated with a click are emitted as appropriate. If the button is checkable, the state of the button is toggled.

This function does nothing if the button is disabled.

See also animateClick().

pub unsafe fn group(&self) -> QPtr<QButtonGroup>[src]

Returns the group that this button belongs to.

Calls C++ function: QButtonGroup* QAbstractButton::group() const.

C++ documentation:

Returns the group that this button belongs to.

If the button is not a member of any QButtonGroup, this function returns 0.

See also QButtonGroup.

pub unsafe fn icon(&self) -> CppBox<QIcon>[src]

This property holds the icon shown on the button

Calls C++ function: QIcon QAbstractButton::icon() const.

C++ documentation:

This property holds the icon shown on the button

The icon's default size is defined by the GUI style, but can be adjusted by setting the iconSize property.

Access functions:

QIcon icon() const
void setIcon(const QIcon &icon)

pub unsafe fn icon_size(&self) -> CppBox<QSize>[src]

This property holds the icon size used for this button.

Calls C++ function: QSize QAbstractButton::iconSize() const.

C++ documentation:

This property holds the icon size used for this button.

The default size is defined by the GUI style. This is a maximum size for the icons. Smaller icons will not be scaled up.

Access functions:

QSize iconSize() const
void setIconSize(const QSize &size)

pub unsafe fn is_checkable(&self) -> bool[src]

This property holds whether the button is checkable

Calls C++ function: bool QAbstractButton::isCheckable() const.

C++ documentation:

This property holds whether the button is checkable

By default, the button is not checkable.

Access functions:

bool isCheckable() const
void setCheckable(bool)

See also checked.

pub unsafe fn is_checked(&self) -> bool[src]

This property holds whether the button is checked

Calls C++ function: bool QAbstractButton::isChecked() const.

C++ documentation:

This property holds whether the button is checked

Only checkable buttons can be checked. By default, the button is unchecked.

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub unsafe fn is_down(&self) -> bool[src]

This property holds whether the button is pressed down

Calls C++ function: bool QAbstractButton::isDown() const.

C++ documentation:

This property holds whether the button is pressed down

If this property is true, the button is pressed down. The signals pressed() and clicked() are not emitted if you set this property to true. The default is false.

Access functions:

bool isDown() const
void setDown(bool)

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QAbstractButton::metaObject() const.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QAbstractButton::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QAbstractButton::qt_metacast(const char* arg1).

pub unsafe fn set_auto_exclusive(&self, arg1: bool)[src]

This property holds whether auto-exclusivity is enabled

Calls C++ function: void QAbstractButton::setAutoExclusive(bool arg1).

C++ documentation:

This property holds whether auto-exclusivity is enabled

If auto-exclusivity is enabled, checkable buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. In an exclusive button group, only one button can be checked at any time; checking another button automatically unchecks the previously checked one.

The property has no effect on buttons that belong to a button group.

autoExclusive is off by default, except for radio buttons.

Access functions:

bool autoExclusive() const
void setAutoExclusive(bool)

See also QRadioButton.

pub unsafe fn set_auto_repeat(&self, arg1: bool)[src]

This property holds whether autoRepeat is enabled

Calls C++ function: void QAbstractButton::setAutoRepeat(bool arg1).

C++ documentation:

This property holds whether autoRepeat is enabled

If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.

Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.

Access functions:

bool autoRepeat() const
void setAutoRepeat(bool)

pub unsafe fn set_auto_repeat_delay(&self, arg1: c_int)[src]

This property holds the initial delay of auto-repetition

Calls C++ function: void QAbstractButton::setAutoRepeatDelay(int arg1).

C++ documentation:

This property holds the initial delay of auto-repetition

If autoRepeat is enabled, then autoRepeatDelay defines the initial delay in milliseconds before auto-repetition kicks in.

This property was introduced in Qt 4.2.

Access functions:

int autoRepeatDelay() const
void setAutoRepeatDelay(int)

See also autoRepeat and autoRepeatInterval.

pub unsafe fn set_auto_repeat_interval(&self, arg1: c_int)[src]

This property holds the interval of auto-repetition

Calls C++ function: void QAbstractButton::setAutoRepeatInterval(int arg1).

C++ documentation:

This property holds the interval of auto-repetition

If autoRepeat is enabled, then autoRepeatInterval defines the length of the auto-repetition interval in millisecons.

This property was introduced in Qt 4.2.

Access functions:

int autoRepeatInterval() const
void setAutoRepeatInterval(int)

See also autoRepeat and autoRepeatDelay.

pub unsafe fn set_checkable(&self, arg1: bool)[src]

This property holds whether the button is checkable

Calls C++ function: void QAbstractButton::setCheckable(bool arg1).

C++ documentation:

This property holds whether the button is checkable

By default, the button is not checkable.

Access functions:

bool isCheckable() const
void setCheckable(bool)

See also checked.

pub unsafe fn set_checked(&self, arg1: bool)[src]

This property holds whether the button is checked

Calls C++ function: [slot] void QAbstractButton::setChecked(bool arg1).

C++ documentation:

This property holds whether the button is checked

Only checkable buttons can be checked. By default, the button is unchecked.

Access functions:

bool isChecked() const
void setChecked(bool)

Notifier signal:

void toggled(bool checked)

See also checkable.

pub unsafe fn set_down(&self, arg1: bool)[src]

This property holds whether the button is pressed down

Calls C++ function: void QAbstractButton::setDown(bool arg1).

C++ documentation:

This property holds whether the button is pressed down

If this property is true, the button is pressed down. The signals pressed() and clicked() are not emitted if you set this property to true. The default is false.

Access functions:

bool isDown() const
void setDown(bool)

pub unsafe fn set_icon(&self, icon: impl CastInto<Ref<QIcon>>)[src]

This property holds the icon shown on the button

Calls C++ function: void QAbstractButton::setIcon(const QIcon& icon).

C++ documentation:

This property holds the icon shown on the button

The icon's default size is defined by the GUI style, but can be adjusted by setting the iconSize property.

Access functions:

QIcon icon() const
void setIcon(const QIcon &icon)

pub unsafe fn set_icon_size(&self, size: impl CastInto<Ref<QSize>>)[src]

This property holds the icon size used for this button.

Calls C++ function: [slot] void QAbstractButton::setIconSize(const QSize& size).

C++ documentation:

This property holds the icon size used for this button.

The default size is defined by the GUI style. This is a maximum size for the icons. Smaller icons will not be scaled up.

Access functions:

QSize iconSize() const
void setIconSize(const QSize &size)

pub unsafe fn set_shortcut(&self, key: impl CastInto<Ref<QKeySequence>>)[src]

This property holds the mnemonic associated with the button

Calls C++ function: void QAbstractButton::setShortcut(const QKeySequence& key).

C++ documentation:

This property holds the mnemonic associated with the button

Access functions:

QKeySequence shortcut() const
void setShortcut(const QKeySequence &key)

pub unsafe fn set_text(&self, text: impl CastInto<Ref<QString>>)[src]

This property holds the text shown on the button

Calls C++ function: void QAbstractButton::setText(const QString& text).

C++ documentation:

This property holds the text shown on the button

If the button has no text, the text() function will return an empty string.

If the text contains an ampersand character ('&'), a shortcut is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous shortcut will be overwritten or cleared if no shortcut is defined by the text. See the QShortcut documentation for details. To display an actual ampersand, use '&&'.

There is no default text.

Access functions:

QString text() const
void setText(const QString &text)

pub unsafe fn shortcut(&self) -> CppBox<QKeySequence>[src]

This property holds the mnemonic associated with the button

Calls C++ function: QKeySequence QAbstractButton::shortcut() const.

C++ documentation:

This property holds the mnemonic associated with the button

Access functions:

QKeySequence shortcut() const
void setShortcut(const QKeySequence &key)

pub unsafe fn text(&self) -> CppBox<QString>[src]

This property holds the text shown on the button

Calls C++ function: QString QAbstractButton::text() const.

C++ documentation:

This property holds the text shown on the button

If the button has no text, the text() function will return an empty string.

If the text contains an ampersand character ('&'), a shortcut is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous shortcut will be overwritten or cleared if no shortcut is defined by the text. See the QShortcut documentation for details. To display an actual ampersand, use '&&'.

There is no default text.

Access functions:

QString text() const
void setText(const QString &text)

pub unsafe fn toggle(&self)[src]

Toggles the state of a checkable button.

Calls C++ function: [slot] void QAbstractButton::toggle().

C++ documentation:

Toggles the state of a checkable button.

See also checked.

Trait Implementations

impl CppDeletable for QPushButton[src]

unsafe fn delete(&self)[src]

Destroys the push button.

Calls C++ function: virtual [destructor] void QPushButton::~QPushButton().

C++ documentation:

Destroys the push button.

impl Deref for QPushButton[src]

type Target = QAbstractButton

The resulting type after dereferencing.

fn deref(&self) -> &QAbstractButton[src]

Calls C++ function: QAbstractButton* static_cast<QAbstractButton*>(QPushButton* ptr).

impl DynamicCast<QCommandLinkButton> for QPushButton[src]

unsafe fn dynamic_cast(ptr: Ptr<QPushButton>) -> Ptr<QCommandLinkButton>[src]

Calls C++ function: QCommandLinkButton* dynamic_cast<QCommandLinkButton*>(QPushButton* ptr).

impl DynamicCast<QPushButton> for QAbstractButton[src]

unsafe fn dynamic_cast(ptr: Ptr<QAbstractButton>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* dynamic_cast<QPushButton*>(QAbstractButton* ptr).

impl DynamicCast<QPushButton> for QWidget[src]

unsafe fn dynamic_cast(ptr: Ptr<QWidget>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* dynamic_cast<QPushButton*>(QWidget* ptr).

impl DynamicCast<QPushButton> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* dynamic_cast<QPushButton*>(QObject* ptr).

impl DynamicCast<QPushButton> for QPaintDevice[src]

unsafe fn dynamic_cast(ptr: Ptr<QPaintDevice>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* dynamic_cast<QPushButton*>(QPaintDevice* ptr).

impl StaticDowncast<QCommandLinkButton> for QPushButton[src]

unsafe fn static_downcast(ptr: Ptr<QPushButton>) -> Ptr<QCommandLinkButton>[src]

Calls C++ function: QCommandLinkButton* static_cast<QCommandLinkButton*>(QPushButton* ptr).

impl StaticDowncast<QPushButton> for QAbstractButton[src]

unsafe fn static_downcast(ptr: Ptr<QAbstractButton>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* static_cast<QPushButton*>(QAbstractButton* ptr).

impl StaticDowncast<QPushButton> for QWidget[src]

unsafe fn static_downcast(ptr: Ptr<QWidget>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* static_cast<QPushButton*>(QWidget* ptr).

impl StaticDowncast<QPushButton> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* static_cast<QPushButton*>(QObject* ptr).

impl StaticDowncast<QPushButton> for QPaintDevice[src]

unsafe fn static_downcast(ptr: Ptr<QPaintDevice>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* static_cast<QPushButton*>(QPaintDevice* ptr).

impl StaticUpcast<QAbstractButton> for QPushButton[src]

unsafe fn static_upcast(ptr: Ptr<QPushButton>) -> Ptr<QAbstractButton>[src]

Calls C++ function: QAbstractButton* static_cast<QAbstractButton*>(QPushButton* ptr).

impl StaticUpcast<QObject> for QPushButton[src]

unsafe fn static_upcast(ptr: Ptr<QPushButton>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QPushButton* ptr).

impl StaticUpcast<QPaintDevice> for QPushButton[src]

unsafe fn static_upcast(ptr: Ptr<QPushButton>) -> Ptr<QPaintDevice>[src]

Calls C++ function: QPaintDevice* static_cast<QPaintDevice*>(QPushButton* ptr).

impl StaticUpcast<QPushButton> for QCommandLinkButton[src]

unsafe fn static_upcast(ptr: Ptr<QCommandLinkButton>) -> Ptr<QPushButton>[src]

Calls C++ function: QPushButton* static_cast<QPushButton*>(QCommandLinkButton* ptr).

impl StaticUpcast<QWidget> for QPushButton[src]

unsafe fn static_upcast(ptr: Ptr<QPushButton>) -> Ptr<QWidget>[src]

Calls C++ function: QWidget* static_cast<QWidget*>(QPushButton* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.