このページでは

CustomTheme QML Type

名前付きカスタムテーマを定義します。詳細...

Import Statement: import Qt.labs.StyleKit

プロパティ

詳しい説明

CustomThemeを使用すると、lightdark 以外のテーマを追加できます。明るいテーマと暗いテーマは、オペレーティングシステムの配色に基づいてautomatically 、適用されますが、CustomThemeは、アプリケーションによって明示的に有効にする必要があります。この違いを除けば、すべてのテーマは同じように機能します。

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"
        }
    }
}

CustomThemeを有効にするには、アプリケーションからStyle::themeName

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

CustomThemeを起動時のデフォルトテーマに設定することもできます:

ApplicationWindow {
    width: 1024
    height: 800
    visible: true

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

スタイルで定義されたカスタムテーマは、実行時にStyle::customThemeNames またはStyle::themeNames から問い合わせることができます。

注意: Qt.labモジュールの型は、将来のバージョンでも互換性が保たれる保証はありません。

ThemeStyle::themeNameStyle::customThemeNamesも参照して ください。

プロパティのドキュメント

name : string

このテーマの名前。このテーマを有効にするためにStyle::themeName に割り当てる値です。

theme : Component

テーマを定義するTheme コンポーネント。テーマがアクティブになったときにのみインスタンス化されます。

テーマで設定されていないプロパティは、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.