CustomTheme QML Type
Definisce un tema personalizzato con nome. Altro...
| Import Statement: | import Qt.labs.StyleKit |
| Status: | Technology preview |
Questo tipo è in anteprima tecnologica ed è soggetto a modifiche.
Proprietà
Descrizione dettagliata
CustomTheme consente di aggiungere temi aggiuntivi oltre a light e dark. Mentre i temi chiaro e scuro vengono applicati automatically in base alla combinazione di colori del sistema operativo, un tema CustomTheme deve essere attivato esplicitamente dall'applicazione. A parte questa differenza, tutti i temi funzionano allo stesso modo.
È possibile definire un numero illimitato di temi personalizzati all’interno di un Style.
Style {
CustomTheme {
name: "HighContrast"
theme: Theme {
control.background.color: "white"
control.background.border.color: "black"
control.background.border.width: 2
}
}
CustomTheme {
name: "Sepia"
theme: Theme {
control.text.color: "#5b4636"
control.background.color: "#f4ecd8"
control.background.border.color: "#c8b99a"
applicationWindow.background.color: "#efe6d0"
}
}
}Per attivare un CustomTheme, impostare Style::themeName sul relativo nome dall’applicazione:
ComboBox {
model: StyleKit.style.availableThemeNames
onCurrentTextChanged: StyleKit.style.themeName = currentText
}È inoltre possibile impostare un CustomTheme come tema predefinito all’avvio:
ApplicationWindow {
width: 1024
height: 800
visible: true
StyleKit.style: MyStyleKitStyle {
themeName: "HighContrast"
}
}I temi personalizzati definiti in uno Style possono essere interrogati in fase di esecuzione tramite ` Style::customThemeNames ` o ` Style::availableThemeNames`.
Nota: non è garantita la compatibilità dei tipi nei moduli Qt.labs nelle versioni future.
Vedi anche Theme, Style::themeName e Style::customThemeNames.
Documentazione sulle proprietà
name : string
Il nome di questo tema. Questo è il valore da assegnare a Style::themeName per attivarlo.
theme : Component
Il componente Theme che definisce il tema. Verrà istanziato solo quando il tema viene attivato.
Le proprietà non impostate nel tema assumono i valori predefiniti in Style.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.