Button QML Type

A push-button control that can be clicked by the user. More...

Import Statement: import QtQuick.Controls 2.0
Since: Qt 5.7
Inherits:

AbstractButton

Inherited By:

ToolButton

Properties

Detailed Description

Button presents a push-button control that can be pushed or clicked by the user. Buttons are normally used to perform an action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No, and Help.

A button in its normal state.

A button that is pressed.

A button that has active focus.

A button that is disabled.

A button emits the signal clicked() when it is activated by the user. Connect to this signal to perform the button's action. Buttons also provide the signals canceled(), doubleClicked(), pressed(), released() and pressAndHold() for long presses.

See the snippet below on how to connect to the button's signals.


  RowLayout {
      Button {
          text: "Ok"
          onClicked: model.submit()
      }
      Button {
          text: "Cancel"
          onClicked: model.revert()
      }
  }

See also Customizing Button and Button Controls.

Property Documentation

autoRepeat : bool

This property holds whether the button repeats pressed(), released() and clicked() signals while the button is pressed and held down.

The default value is false.


checkable : bool

This property holds whether the button is checkable.


flat : bool

This property holds whether the button is flat.

A flat button typically does not draw a background unless it is pressed or checked.

The default value is false.


highlighted : bool

This property holds whether the button is highlighted.

A button can be highlighted in order to draw the user's attention towards it. It has no effect on keyboard interaction.

The default value is false.