T_TextBox.qml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import QtQuick.Window
  5. import FluentUI
  6. import "../component"
  7. FluScrollablePage{
  8. title:"TextBox"
  9. leftPadding:10
  10. rightPadding:10
  11. bottomPadding:20
  12. spacing: 0
  13. FluArea{
  14. Layout.fillWidth: true
  15. height: 68
  16. paddings: 10
  17. Layout.topMargin: 20
  18. FluTextBox{
  19. Layout.topMargin: 20
  20. placeholderText: "单行输入框"
  21. Layout.preferredWidth: 300
  22. disabled:text_box_switch.selected
  23. anchors{
  24. verticalCenter: parent.verticalCenter
  25. left: parent.left
  26. }
  27. }
  28. Row{
  29. spacing: 5
  30. anchors{
  31. verticalCenter: parent.verticalCenter
  32. right: parent.right
  33. }
  34. FluToggleSwitch{
  35. id:text_box_switch
  36. Layout.alignment: Qt.AlignRight
  37. text:"Disabled"
  38. }
  39. }
  40. }
  41. CodeExpander{
  42. Layout.fillWidth: true
  43. Layout.topMargin: -1
  44. code:'FluTextBox{
  45. placeholderText:"单行输入框"
  46. }'
  47. }
  48. FluArea{
  49. Layout.fillWidth: true
  50. height: 68
  51. paddings: 10
  52. Layout.topMargin: 20
  53. FluPasswordBox{
  54. Layout.topMargin: 20
  55. placeholderText: "请输入密码"
  56. Layout.preferredWidth: 300
  57. disabled:password_box_switch.selected
  58. anchors{
  59. verticalCenter: parent.verticalCenter
  60. left: parent.left
  61. }
  62. }
  63. Row{
  64. spacing: 5
  65. anchors{
  66. verticalCenter: parent.verticalCenter
  67. right: parent.right
  68. }
  69. FluToggleSwitch{
  70. id:password_box_switch
  71. Layout.alignment: Qt.AlignRight
  72. text:"Disabled"
  73. }
  74. }
  75. }
  76. CodeExpander{
  77. Layout.fillWidth: true
  78. Layout.topMargin: -1
  79. code:'FluPasswordBox{
  80. placeholderText:"请输入密码"
  81. }'
  82. }
  83. FluArea{
  84. Layout.fillWidth: true
  85. height: 36+multiine_textbox.height
  86. paddings: 10
  87. Layout.topMargin: 20
  88. FluMultilineTextBox{
  89. id:multiine_textbox
  90. Layout.topMargin: 20
  91. placeholderText: "多行输入框"
  92. Layout.preferredWidth: 300
  93. disabled:text_box_multi_switch.selected
  94. anchors{
  95. verticalCenter: parent.verticalCenter
  96. left: parent.left
  97. }
  98. }
  99. Row{
  100. spacing: 5
  101. anchors{
  102. verticalCenter: parent.verticalCenter
  103. right: parent.right
  104. }
  105. FluToggleSwitch{
  106. id:text_box_multi_switch
  107. Layout.alignment: Qt.AlignRight
  108. text:"Disabled"
  109. }
  110. }
  111. }
  112. CodeExpander{
  113. Layout.fillWidth: true
  114. Layout.topMargin: -1
  115. code:'FluMultilineTextBox{
  116. placeholderText:"多行输入框"
  117. }'
  118. }
  119. FluArea{
  120. Layout.fillWidth: true
  121. height: 68
  122. paddings: 10
  123. Layout.topMargin: 20
  124. FluAutoSuggestBox{
  125. Layout.topMargin: 20
  126. placeholderText: "AutoSuggestBox"
  127. Layout.preferredWidth: 300
  128. items:generateRandomNames(100)
  129. disabled:text_box_suggest_switch.selected
  130. anchors{
  131. verticalCenter: parent.verticalCenter
  132. left: parent.left
  133. }
  134. }
  135. Row{
  136. spacing: 5
  137. anchors{
  138. verticalCenter: parent.verticalCenter
  139. right: parent.right
  140. }
  141. FluToggleSwitch{
  142. id:text_box_suggest_switch
  143. Layout.alignment: Qt.AlignRight
  144. text:"Disabled"
  145. }
  146. }
  147. }
  148. CodeExpander{
  149. Layout.fillWidth: true
  150. Layout.topMargin: -1
  151. code:'FluAutoSuggestBox{
  152. placeholderText:"AutoSuggestBox"
  153. }'
  154. }
  155. function generateRandomNames(numNames) {
  156. const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  157. const names = [];
  158. function generateRandomName() {
  159. const nameLength = Math.floor(Math.random() * 5) + 4;
  160. let name = '';
  161. for (let i = 0; i < nameLength; i++) {
  162. const letterIndex = Math.floor(Math.random() * 26);
  163. name += alphabet.charAt(letterIndex);
  164. }
  165. return name;
  166. }
  167. for (let i = 0; i < numNames; i++) {
  168. const name = generateRandomName();
  169. names.push({title:name});
  170. }
  171. return names;
  172. }
  173. }