このページでは

CustomTheme QML Type

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

Import Statement: import Qt.labs.StyleKit
Status: Technology preview

このタイプはテクノロジープレビュー段階にあり、変更される可能性があります。

プロパティ

詳細説明

CustomTheme を使用すると、light やdark 以外のテーマを追加できます。ライトテーマとダークテーマは、オペレーティングシステムのカラースキームに基づいて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.availableThemeNames
    onCurrentTextChanged: StyleKit.style.themeName = currentText
}

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

ApplicationWindow {
    width: 1024
    height: 800
    visible: true

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

Style内で定義されたカスタムテーマは、実行時にStyle::customThemeNames またはStyle::availableThemeNames から取得できます。

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

Theme 、Style::themeName 、およびStyle::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.