FluentUI/Gallery/res/qml/page/T_AutoSuggestBox.qml
yxdy a44db97aa3
Some checks failed
Gallery App Build / Windows (push) Has been cancelled
Gallery App Build / macOS (push) Has been cancelled
Gallery App Build / Ubuntu (push) Has been cancelled
init
2025-02-12 10:31:20 +08:00

45 lines
1.0 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import FluentUI.Controls
import Gallery
ScrollablePage {
title: qsTr("AutoSuggestBox")
CardHighlight{
Layout.fillWidth: true
codeSnippet:
`import QtQuick
import QtQuick.Controls
import FluentUI.Controls
Column{
AutoSuggestBox{
items: generateRandomNames(100)
placeholderText: "AutoSuggest"
}
function generateRandomNames(numNames) {
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()
names.push({title:name})
}
return names
}
}
`}
}