RadioButton.qml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2021 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Controls module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:COMM$
  9. **
  10. ** Commercial License Usage
  11. ** Licensees holding valid commercial Qt licenses may use this file in
  12. ** accordance with the commercial license agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and The Qt Company. For licensing terms
  15. ** and conditions see https://www.qt.io/terms-conditions. For further
  16. ** information use the contact form at https://www.qt.io/contact-us.
  17. **
  18. ** $QT_END_LICENSE$
  19. **
  20. **
  21. **
  22. **
  23. **
  24. **
  25. **
  26. **
  27. **
  28. **
  29. **
  30. **
  31. **
  32. **
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ****************************************************************************/
  39. import QtQuick 2.2
  40. import QtQuick.Controls 1.2
  41. import QtQuick.Controls.Private 1.0
  42. /*!
  43. \qmltype RadioButton
  44. \inqmlmodule QtQuick.Controls
  45. \since 5.1
  46. \ingroup controls
  47. \brief A radio button with a text label.
  48. \image radiobutton.png
  49. A RadioButton is an option button that can be switched on (checked) or off
  50. (unchecked). Radio buttons typically present the user with a "one of many"
  51. choices. In a group of radio buttons, only one radio button can be
  52. checked at a time; if the user selects another button, the previously
  53. selected button is switched off.
  54. \qml
  55. GroupBox {
  56. title: "Tab Position"
  57. RowLayout {
  58. ExclusiveGroup { id: tabPositionGroup }
  59. RadioButton {
  60. text: "Top"
  61. checked: true
  62. exclusiveGroup: tabPositionGroup
  63. }
  64. RadioButton {
  65. text: "Bottom"
  66. exclusiveGroup: tabPositionGroup
  67. }
  68. }
  69. }
  70. \endqml
  71. You can create a custom appearance for a RadioButton by
  72. assigning a \l {RadioButtonStyle}.
  73. */
  74. AbstractCheckable {
  75. id: radioButton
  76. activeFocusOnTab: true
  77. Accessible.name: text
  78. Accessible.role: Accessible.RadioButton
  79. /*!
  80. The style that should be applied to the radio button. Custom style
  81. components can be created with:
  82. \codeline Qt.createComponent("path/to/style.qml", radioButtonId);
  83. */
  84. style: Settings.styleComponent(Settings.style, "RadioButtonStyle.qml", radioButton)
  85. __cycleStatesHandler: function() { checked = !checked; }
  86. }