En esta página

CustomTheme QML Type

Define un tema personalizado con nombre. Más...

Import Statement: import Qt.labs.StyleKit

Propiedades

Descripción detallada

CustomTheme le permite añadir temas adicionales más allá de light y dark. Mientras que los temas claros y oscuros se aplican automatically basándose en el esquema de colores del sistema operativo, un CustomTheme debe ser activado explícitamente por la aplicación. Aparte de esta diferencia, todos los temas funcionan igual.

Puede definir cualquier número de temas personalizados dentro de 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"
        }
    }
}

Para activar un CustomTheme, configure Style::themeName con su nombre desde la aplicación:

ComboBox {
    model: StyleKit.style.themeNames
    onCurrentTextChanged: StyleKit.style.themeName = currentText
}

También puede establecer un CustomTheme como tema predeterminado al inicio:

ApplicationWindow {
    width: 1024
    height: 800
    visible: true

    StyleKit.style: MyStyleKitStyle {
        themeName: "HighContrast"
    }
}

Los temas personalizados definidos en un Estilo pueden consultarse en tiempo de ejecución desde Style::customThemeNames o Style::themeNames.

Nota: No se garantiza que los tipos de los módulos Qt.labs sigan siendo compatibles en futuras versiones.

Véase también Theme, Style::themeName, y Style::customThemeNames.

Documentación de propiedades

name : string

El nombre de este tema. Es el valor que se asigna a Style::themeName para activarlo.

theme : Component

El componente Theme que define el tema. Sólo se instanciará cuando se active el tema.

Las propiedades no definidas en el tema vuelven a las definidas en 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.