FluentUI/example/T_TextBox.qml

155 lines
3.7 KiB
QML
Raw Normal View History

2023-03-30 21:52:55 +08:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Window
import FluentUI
2023-04-06 17:32:21 +08:00
import "./component"
2023-03-02 12:20:16 +08:00
2023-03-10 18:08:32 +08:00
FluScrollablePage{
title:"TextBox"
2023-03-28 17:53:46 +08:00
leftPadding:10
rightPadding:10
bottomPadding:20
2023-04-06 17:32:21 +08:00
spacing: 0
2023-03-10 18:08:32 +08:00
2023-04-06 17:32:21 +08:00
FluArea{
Layout.fillWidth: true
height: 68
paddings: 10
2023-03-10 18:08:32 +08:00
Layout.topMargin: 20
2023-04-06 17:32:21 +08:00
FluTextBox{
Layout.topMargin: 20
placeholderText: "单行输入框"
Layout.preferredWidth: 300
disabled:text_box_switch.selected
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:text_box_switch
Layout.alignment: Qt.AlignRight
text:"Disabled"
}
}
2023-03-06 18:08:01 +08:00
}
2023-04-06 17:32:21 +08:00
CodeExpander{
Layout.fillWidth: true
2023-04-19 17:25:46 +08:00
Layout.topMargin: -1
2023-04-06 17:32:21 +08:00
code:'FluTextBox{
placeholderText:"单行输入框"
}'
2023-03-10 18:08:32 +08:00
}
2023-04-06 17:32:21 +08:00
FluArea{
Layout.fillWidth: true
height: 68
paddings: 10
2023-03-10 18:08:32 +08:00
Layout.topMargin: 20
2023-04-06 17:32:21 +08:00
FluMultilineTextBox{
Layout.topMargin: 20
placeholderText: "多行输入框"
Layout.preferredWidth: 300
disabled:text_box_multi_switch.selected
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:text_box_multi_switch
Layout.alignment: Qt.AlignRight
text:"Disabled"
}
}
}
CodeExpander{
Layout.fillWidth: true
2023-04-19 17:25:46 +08:00
Layout.topMargin: -1
2023-04-06 17:32:21 +08:00
code:'FluMultilineTextBox{
placeholderText:"多行输入框"
}'
2023-03-20 18:22:32 +08:00
}
2023-04-06 17:32:21 +08:00
FluArea{
Layout.fillWidth: true
height: 68
paddings: 10
2023-03-20 18:22:32 +08:00
Layout.topMargin: 20
2023-04-06 17:32:21 +08:00
FluAutoSuggestBox{
Layout.topMargin: 20
placeholderText: "AutoSuggestBox"
Layout.preferredWidth: 300
items:generateRandomNames(100)
disabled:text_box_suggest_switch.selected
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:text_box_suggest_switch
Layout.alignment: Qt.AlignRight
text:"Disabled"
}
}
}
CodeExpander{
Layout.fillWidth: true
2023-04-19 17:25:46 +08:00
Layout.topMargin: -1
2023-04-06 17:32:21 +08:00
code:'FluAutoSuggestBox{
placeholderText:"AutoSuggestBox"
}'
2023-03-09 15:49:37 +08:00
}
2023-04-06 17:32:21 +08:00
2023-03-09 15:49:37 +08:00
function generateRandomNames(numNames) {
2023-03-10 18:08:32 +08:00
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const names = [];
function generateRandomName() {
const nameLength = Math.floor(Math.random() * 5) + 4;
let name = '';
for (let i = 0; i < nameLength; i++) {
const letterIndex = Math.floor(Math.random() * 26);
name += alphabet.charAt(letterIndex);
}
return name;
}
for (let i = 0; i < numNames; i++) {
const name = generateRandomName();
2023-03-30 17:16:57 +08:00
names.push({title:name});
2023-03-02 12:20:16 +08:00
}
2023-03-10 18:08:32 +08:00
return names;
2023-03-02 12:20:16 +08:00
}
2023-03-09 15:49:37 +08:00
2023-03-02 12:20:16 +08:00
}