ControlStyle QML Type
normal 状態にあるコントロールのスタイルを定義します。詳細...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: | |
| Inherited By: | |
| Status: | Technology preview |
この型はテクノロジープレビュー段階にあり、変更される可能性があります。
プロパティ
- variations : list<StyleVariation>
詳細な説明
ControlStyleは、Control のスタイル設定方法を定義します。そのAPIは、Qt Quick のControlのAPIとほぼ同様です。background 、indicator 、handle 、text といったデリゲート用のプロパティ群に加え、padding やspacing といったレイアウトプロパティも提供しています。Qt Quick のControlにおけるControl のAPIに慣れている方であれば、ControlStyleのAPIも容易に理解できるはずです。
ControlStyleはControlStateStyle を継承しています。これは、ControlStyleが通常状態を表すためです。ControlStyleに直接設定されたプロパティは、他の状態がアクティブでないときのコントロールの外観を記述します。状態固有のオーバーライドは、hovered 、pressed 、checked などのネストされた状態を通じて設定されます。
Each stylable control Style 、 、または 内のものはすべてControlStyleです。たとえば、以下のスニペットでは、 、 、および はいずれもControlStyleです:Theme StyleVariation control button radioButton
Style {
control {
padding: 6
text {
color: "white"
}
background {
radius: 4
border.color: "gray"
}
indicator {
width: 20
height: 20
border.width: 1
}
handle {
width: 20
height: 20
radius: 10
}
}
button {
background {
width: 120
shadow.opacity: 0.6
shadow.verticalOffset: 2
shadow.horizontalOffset: 2
shadow.color: "gray"
color: "lightsteelblue"
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.alpha("black", 0.0)}
GradientStop { position: 1.0; color: Qt.alpha("black", 0.2)}
}
}
hovered {
background.color: "lightslategrey"
}
pressed {
background.scale: 0.95
}
}
radioButton {
}
checkBox {
}
slider {
}
// etc...
}All stylable controls 、Style 、Theme 、StyleVariation 、ControlStateStyle 、およびDelegateStyleも参照してください 。
プロパティのドキュメント
variations : list<StyleVariation>
このコントロールタイプに対するtype variations の一覧。
タイプバリエーションは、このコントロール型の子(または子孫)であるコントロールに対して、別のスタイルを適用します。たとえば、これを使用すると、frame 内のすべてのbuttons に対して、他の場所にあるボタンとは異なるスタイルを適用できます。
Style {
frame {
variations: StyleVariation {
button {
text.color: "ghostwhite"
background.border.width: 0
background.color: "slategrey"
}
}
}
groupBox {
// groupBox falls back to frame. Therefore, if the varations set on a
// frame is not wanted on a groupBox, just override it and set it back to [].
variations: []
}
}インスタンスバリエーション(StyleVariation::variations 添付プロパティを介してアプリケーションから特定のコントロールインスタンスに適用されるもの)とは異なり、タイプバリエーションは、Style 内のそのコントロール型のすべてのインスタンスに適用され、アプリケーション側での明示的な設定は不要です。
「StyleVariation」も参照してください 。
© 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.