StyleReader QML Type
特定のコントロールのアクティブなスタイルからプロパティを読み取ります。詳細...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: | |
| Status: | Technology preview |
この型はテクノロジープレビュー段階にあり、変更される可能性があります。
プロパティ
- checked : bool
- controlType : enumeration
- enabled : bool
- focused : bool
- font : font
- global : ControlStyleProperties
- highlighted : bool
- hovered : bool
- palette : palette
- pressed : bool
- vertical : bool
詳細な説明
StyleReaderは、Qt Quick Controlsのコントロールと active style との間のブリッジとなるものです。これによって、コントロールおよびそのデリゲートがバインドすべきすべてのスタイルプロパティ(backgrounds 、indicators 、handles 、text 、padding など)が公開されます。StyleKit のすべての組み込みコントロールは、この目的のために内部でStyleReaderを使用しています。
状態プロパティ(hovered 、pressed 、focused 、checked 、highlighted など)は、コントロールがどの状態にあるかをStyleReaderに伝えます。StyleReaderはこれらを使用して、Style から正しいプロパティ値を解決・読み取り、その際、Themes 、StyleVariations 、fallback types 、およびプロパティの伝播を考慮に入れます。
CustomControl を実装する際は、組み込みコントロールと同じアプローチに従うことができます:
// Main.qml
component CustomButton : Rectangle {
StyleReader {
id: styleReader
controlType: StyleReader.Button
hovered: hoverHandler.hovered
pressed: tapHandler.pressed
palette: app.palette
}
implicitWidth: styleReader.background.width
implicitHeight: styleReader.background.height
color: styleReader.background.color
radius: styleReader.background.radius
HoverHandler { id: hoverHandler }
TapHandler { id: tapHandler }
Text {
font: styleReader.font
anchors.centerIn: parent
text: "ok"
}
}注: ControlStyleProperties から継承されるスタイルプロパティは 、Style に直接対応するものではありません。それらは、アクティブなtransition 中に補間される可能性のある値のキャッシュを反映したものです。これらに書き込んでも、Style 内の対応するプロパティは更新されず、進行中の遷移に干渉する可能性があります。スタイルプロパティを変更する必要がある場合は、Style に直接書き込んでください。
注: Qt.labs モジュール内の型は、将来のバージョンでも互換性が維持されるとは限りません。
関連項目: CustomControl 、Style 、StyleVariation.controlType 、およびStyleKit プロパティの解決。
プロパティのドキュメント
checked : bool
コントロールがチェックされているかどうか。
これをコントロールのchecked プロパティにバインドします。
デフォルト値は `false` です。
「ControlStateStyle.checked」も参照してください 。
controlType : enumeration
このリーダーがStyle 内のどのコントロールタイプからプロパティを読み取るかを指定します。これは、以下の事前定義済み値のいずれかに設定するか、Style で定義されたcustom control type に設定することができます。
| 定数 | 説明 |
|---|---|
StyleReader.BusyIndicator | BusyIndicator |
StyleReader.Button | Button |
StyleReader.CheckBox | CheckBox |
StyleReader.CheckDelegate | CheckDelegate |
StyleReader.ComboBox | ComboBox |
StyleReader.DelayButton | DelayButton |
StyleReader.Dial | Dial |
StyleReader.Dialog | Dialog |
StyleReader.DialogButtonBox | DialogButtonBox |
StyleReader.Frame | Frame |
StyleReader.GroupBox | GroupBox |
StyleReader.ItemDelegate | ItemDelegate |
StyleReader.Label | Label |
StyleReader.Menu | Menu |
StyleReader.MenuBar | MenuBar |
StyleReader.MenuBarItem | MenuBarItem |
StyleReader.MenuItem | MenuItem |
StyleReader.MenuSeparator | MenuSeparator |
StyleReader.Page | Page |
StyleReader.PageIndicator | PageIndicator |
StyleReader.Pane | Pane |
StyleReader.Popup | Popup |
StyleReader.ProgressBar | ProgressBar |
StyleReader.RadioButton | RadioButton |
StyleReader.RadioDelegate | RadioDelegate |
StyleReader.RoundButton | RoundButton |
StyleReader.ScrollBar | ScrollBar |
StyleReader.ScrollView | ScrollView |
StyleReader.SearchField | SearchField |
StyleReader.Slider | Slider |
StyleReader.SpinBox | SpinBox |
StyleReader.SwipeDelegate | SwipeDelegate |
StyleReader.Switch | Switch |
StyleReader.SwitchDelegate | SwitchDelegate |
StyleReader.TabBar | TabBar |
StyleReader.TabButton | TabButton |
StyleReader.TextArea | TextArea |
StyleReader.TextField | TextField |
StyleReader.ToolBar | ToolBar |
StyleReader.ToolButton | ToolButton |
StyleReader.ToolSeparator | ToolSeparator |
「StyleVariation.controlType」も参照してください 。
enabled : bool
コントロールが有効かどうか。
これをコントロールのenabled プロパティにバインドします。
デフォルト値は `true` です。
「ControlStateStyle.disabled」も参照してください 。
focused : bool
コントロールにアクティブなフォーカスがあるかどうか。
これをコントロールのactiveFocus プロパティにバインドします。
デフォルト値は `false` です。
「ControlStateStyle.focused」も参照してください 。
font : font [read-only]
style で定義されている、このコントロールタイプに適用されるフォントです。これには、スタイルのtext プロパティで設定されたフォントのオーバーライドも反映されます。
コントロールのfont プロパティをこのプロパティにバインドしてください。
注: `hovered`、`pressed `、`palette ` といったプロパティ(これらはコントロールから `StyleReader ` に転送されます)とは異なり、 `font` は出力プロパティです。コントロールの `font ` プロパティをこの値にバインドしてください。その逆ではありません。
global : ControlStyleProperties [read-only]
進行中のtransition をバイパスして、スタイルプロパティに直接アクセスできるようにします。
状態遷移が進行中の場合、StyleReader から読み込まれたスタイルプロパティは、補間された値を返すことがあります。プロパティパスにglobal を先頭につけることで、遷移をバイパスし、最終状態の値を即座に取得できます。
たとえば、hovered からpressed へ遷移している場合、background.color は、hovered 状態のcolor とpressed 状態の色の中間となる補間値を返す可能性があります。一方、global.background.color は、押下状態の色を直接返します。
transitionsEnabledも参照してください 。
highlighted : bool
コントロールが強調表示されているかどうか。
これをコントロールのhighlighted プロパティにバインドします。
デフォルト値は `false` です。
「ControlStateStyle.highlighted」も参照してください 。
hovered : bool
コントロールにマウスカーソルがホバーしているかどうか。
これをコントロールのhovered プロパティにバインドします。
デフォルト値はfalse です。
「ControlStateStyle.hovered」も参照してください 。
palette : palette
コントロールのパレット。StyleKitは、これを使用して、Style 内のpalette にバインドされた色プロパティを解決します。
これをコントロールのpalette プロパティにバインドします。
「Style.palette」も参照してください 。
pressed : bool
コントロールが押されているかどうか。
これをコントロールのpressed プロパティにバインドします。
デフォルト値はfalse です。
「ControlStateStyle.pressed」も参照してください 。
vertical : bool
コントロールが縦向きかどうか。
これをコントロールのorientation にバインドします。
デフォルト値は `false` です。
「ControlStateStyle.vertical」も参照してください 。
© 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.