StylableControls QML Type
スタイル設定が可能な制御型を含む抽象基底型。詳細...
| Import Statement: | import Qt.labs.StyleKit |
| Inherited By: | AbstractStyle, Style, StyleVariation, and Theme |
| Status: | Technology preview |
この型はテクノロジープレビュー段階にあり、変更される可能性があります。
プロパティ
- abstractButton : ControlStyle
- applicationWindow : ControlStyle
- busyIndicator : ControlStyle
- button : ControlStyle
- checkBox : ControlStyle
- checkDelegate : ControlStyle
- comboBox : ControlStyle
- control : ControlStyle
- delayButton : ControlStyle
- dial : ControlStyle
- dialog : ControlStyle
- dialogButtonBox : ControlStyle
- flatButton : ControlStyle
- frame : ControlStyle
- groupBox : ControlStyle
- itemDelegate : ControlStyle
- label : ControlStyle
- menu : ControlStyle
- menuBar : ControlStyle
- menuBarItem : ControlStyle
- menuItem : ControlStyle
- menuSeparator : ControlStyle
- page : ControlStyle
- pageIndicator : ControlStyle
- pane : ControlStyle
- popup : ControlStyle
- progressBar : ControlStyle
- radioButton : ControlStyle
- radioDelegate : ControlStyle
- roundButton : ControlStyle
- scrollBar : ControlStyle
- scrollIndicator : ControlStyle
- scrollView : ControlStyle
- searchField : ControlStyle
- slider : ControlStyle
- spinBox : ControlStyle
- swipeDelegate : ControlStyle
- switchControl : ControlStyle
- switchDelegate : ControlStyle
- tabBar : ControlStyle
- tabButton : ControlStyle
- textArea : ControlStyle
- textField : ControlStyle
- textInput : ControlStyle
- toolBar : ControlStyle
- toolButton : ControlStyle
- toolSeparator : ControlStyle
方法
- ControlStyle getControlStyle(controlType)
詳細な説明
StylableControls は抽象基底型です。これには、Style 、Theme 、またはStyleVariation によってスタイル設定が可能な各コントロール型に対応するControlStyle が含まれています。
これらのコントロール型は階層構造を成しており、基底型に設定されたプロパティは、より具体的な型へと継承されます。たとえば、abstractButton.background.radius に半径4を割り当てると、button 、checkBox 、radioButton などのすべてのボタン型に半径4が適用されます。
このページに掲載されているスニペットは、各コントロールタイプのスタイル設定に使用できる主要なプロパティのいくつかを示していますが、決して網羅的なものではありません。『ControlStyle 』および『DelegateStyle 』のドキュメントに記載されているように、他にも多くのプロパティが利用可能です。 実際には、fallback style がすでに適切なデフォルト値を提供しているため、一部のプロパティは省略することも可能です。つまり、スニペットからプロパティを単に削除したとしても、代わりにフォールバックスタイルから値が読み込まれるため、外観には影響しない場合があります。
注: Qt.labs モジュール内の型は、将来のバージョンでも互換性が維持されるとは限りません。
「StyleKit プロパティの解決」も参照してください 。
プロパティのドキュメント
abstractButton : ControlStyle
Button 、CheckBox 、RadioButton 、Switch 、RoundButton を含む、すべてのボタン型コントロールのスタイル設定を行うためのグループ化されたプロパティです。プロパティが設定されていない場合は、control が適用されます。
abstractButton.background.radius: 4 // all buttons get a radius of 4
checkBox.indicator.radius: 2 // except check boxes, which get a radius of 2「制御型」も参照してください 。
applicationWindow : ControlStyle
ApplicationWindow のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
ウィンドウの背景色を設定するには、applicationWindow を使用します:
light: Theme {
applicationWindow.background.color: "#f0f0f0"
}
dark: Theme {
applicationWindow.background.color: "#404040"
}注: この設定を有効にするには、アプリケーションは `Window` ではなく `ApplicationWindow` を使用する必要があります。
busyIndicator : ControlStyle
BusyIndicator のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
busyIndicator {
background {
visible: false
width: 48
height: 48
}
indicator {
fillWidth: true
fillHeight: true
color: "transparent"
border.width: 0
foreground {
radius: 255
color: palette.accent
}
}
}StyleKitには、回転インジケーターのアニメーションをスタイル設定するための専用プロパティは用意されていません。回転インジケーターの形状やアニメーションを変更するには、代わりにカスタムインジケーターのフォアグラウンドdelegate を実装する必要があります:
busyIndicator {
background {
visible: false
width: 48
height: 48
}
indicator {
fillWidth: true
fillHeight: true
color: "transparent"
border.width: 0
foreground {
radius: 255
color: palette.accent
delegate: Text {
required property DelegateStyle delegateStyle
required property QtObject control
opacity: control.running ? 1 : 0
Behavior on opacity { NumberAnimation{} }
text: "↻"
color: delegateStyle.color
font.pixelSize: 20
RotationAnimation on rotation {
from: 0
to: 360
duration: 1000
loops: Animation.Infinite
running: control.running
}
}
}
}
}button : ControlStyle
Button のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
button {
background {
width: 120
height: 40
shadow {
opacity: 0.6
color: "gray"
verticalOffset: 2
horizontalOffset: 2
}
color: "cornflowerblue"
gradient: Gradient {
// The gradient is drawn on top of the 'background.color', so
// we use semi-transparent stops to give the button some shading
// while letting the base color show through. This makes it easier
// to change the color, but keep the shading, in the hovered state below.
GradientStop { position: 0.0; color: Qt.alpha("black", 0.0)}
GradientStop { position: 1.0; color: Qt.alpha("black", 0.2)}
}
}
text.color: "white"
hovered.background.color: "royalblue"
pressed.background.scale: 0.95
}checkBox : ControlStyle
CheckBox のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
checkBox {
// Hide the button background; show only the indicator and text
background.visible: false
indicator {
color: "white"
border.color: "darkslategray"
foreground {
color: "transparent"
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
image.color: palette.accent
// Hide the checkmark when the checkbox is not checked
visible: false
}
}
// Show the checkmark when the checkbox is checked
checked.indicator.foreground.visible: true
}checkDelegate : ControlStyle
CheckDelegate のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、itemDelegate にフォールバックします。
checkDelegate {
text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
background {
radius: 0
color: "white"
border.width: 0
}
indicator {
border.color: "darkslategray"
foreground {
color: "transparent"
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
image.color: palette.accent
// Hide the checkmark when the checkbox is not checked
visible: false
}
}
hovered.background.color: "#f0f0f0"
// Show the checkmark when the checkbox is checked
checked.indicator.foreground.visible: true
}comboBox : ControlStyle
ComboBox のスタイリング用グループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
注: ポップアップのスタイルは `popup` を通じて、その項目のスタイルは `itemDelegate` を通じて設定してください。
comboBox {
text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
background.topLeftRadius: 4
background.topRightRadius: 4
indicator {
// Show only the dropdown arrow, not the indicator background
color: "transparent"
border.width: 0
foreground {
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/drop-indicator.png"
image.color: "black"
}
}
}control : ControlStyle
すべてのコントロールのスタイル設定を行うためのグループ化されたプロパティです。
control これはコントロール階層における基底型であり、ここで設定されたプロパティは他のすべてのコントロール型のデフォルト値として機能します。例えば、control.width: 200 を設定すると、ボタン、スクロールインジケーター、その他すべてのコントロールを含め、すべてのコントロールの幅が200ピクセルになります。 また、スタイル階層の上位レベルから継承された値(Theme に対する `Style ` や、Style に対する `fallbackStyle `など)も上書きされます。これには、ホバー効果やその他の状態に基づく動作も含まれます。control は控えめに使用し、可能であればabstractButton やpane のような、より具体的な基底型を優先してください。
control {
padding: 8
background.radius: 4
}delayButton : ControlStyle
DelayButton のスタイリング用のグループ化プロパティ。
遅延ボタンの場合、進行状況はインジケーターを通じて表現されます。デフォルトでは、インジケーター自体は透明で境界線がないため、インジケーターが徐々に埋まっていくにつれて、その前景色のみが表示されます。
設定されていないプロパティは、abstractButton にフォールバックします。
delayButton {
padding: 0
indicator {
fillWidth: true
fillHeight: true
color: "transparent"
border.width: 0
foreground.color: palette.accent
}
checked.indicator.foreground.color: palette.accent.darker(1.2)
}dial : ControlStyle
Dial のスタイル設定用のグループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
dial {
spacing: 0
handle.width: 15
handle.height: 15
background.visible: false
indicator {
width: 60
height: 60
radius: 255
foreground {
fillWidth: true
fillHeight: true
width: 6
height: 6
color: palette.accent
}
}
}dialog : ControlStyle
Dialog のスタイリング用グループ化プロパティ。
設定されていないプロパティは、popup にフォールバックします。
dialog {
text {
padding: 12
alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
background.color: "white"
}dialogButtonBox : ControlStyle
DialogButtonBox のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、pane にフォールバックします。
dialogButtonBox {
background {
height: 40
radius: 0
color: "transparent"
border.width: 0
}
}flatButton : ControlStyle
フラットボタン(通常状態で背景が表示されないボタン)のスタイル設定用のグループ化されたプロパティです。Button.flat がtrue に設定されている場合、このスタイル設定はButton に適用されます。
設定されていないプロパティは、abstractButton にフォールバックします。
flatButton {
// Hide background normally, show on hover
background.visible: false
hovered.background.visible: true
}frame : ControlStyle
Frame のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、pane にフォールバックします。
frame {
background {
color: "#fafafa"
border.color: "#d0d0d0"
radius: 4
}
}groupBox : ControlStyle
GroupBox のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、frame にフォールバックします。
groupBox {
// A group box is a container for other controls, so we give it some
// padding to avoid the child controls to be too close to the border
padding: 20
// Move the label to the right, to match the radius of the background
text.leftPadding: 6
text.color: "darkslategray"
background {
// Move the frame down, below the text label
topMargin: 30
radius: 6
color: "#f8f8f8"
border.color: "#d0d0d0"
}
}itemDelegate : ControlStyle
ItemDelegate のスタイル設定用のグループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
注: Qt Quick Controlsでは 、ItemDelegate はAbstractButton から継承されます。一方、StyleKit では、itemDelegate はabstractButton ではなくcontrol にフォールバックします。これは、デリゲートは通常、ボタンとは大きく異なるスタイル(フラットで、境界線やドロップシャドウがないなど)が適用されるためです。
itemDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
hovered.background.color: "#f0f0f0"
}label : ControlStyle
Label のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
light: Theme {
// Labels typically have no background, so set background.visible to false.
// Alternatively, hiding the background for labels can be done once for all
// themes by setting Style.label.background.visible: false.
label.background.visible: false
label.text.color: "black"
}
dark: Theme {
label.background.visible: false
label.text.color: "white"
}menu : ControlStyle
Menu のスタイリング用のグループ化されたプロパティ。
設定されていないプロパティは、popup にフォールバックします。
menu {
background {
width: 200
height: 40
border.color: "darkslategray"
radius: 4
}
}menuBar : ControlStyle
MenuBar のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
注: MenuBar 、MenuBarItem 、およびMenuSeparator へのスタイル設定は 、通常、ネイティブではないメニューバーにのみ影響します。MenuBar がネイティブメニューバーとして実装されている場合、そのデリゲートはレンダリングに使用されないため、StyleKitのスタイルプロパティは視覚的な効果をもたらさない可能性があります。詳細については、「ネイティブメニューバー」を参照してください。
menuBar {
background {
radius: 0
border.width: 0
}
}menuBarItem : ControlStyle
MenuBar 内のメニュー項目のスタイル設定を行うためのグループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
注: Qt Quick Controlsでは 、MenuBarItem はAbstractButton から継承されます。しかし、StyleKit では、menuBarItem は独立したコントロールタイプであり、メニューバーの項目は通常、通常のボタンとは大きく異なるスタイル(フラット、境界線やドロップシャドウなしなど)が適用されるため、abstractButton ではなくcontrol にフォールバックします。
menuBarItem {
text.alignment: Qt.AlignLeft | Qt.AlignVCenter
background {
radius: 0
color: "transparent"
border.width: 0
}
hovered.background.color: "#c0c0c0"
}menuItem : ControlStyle
MenuItem のスタイル設定用のグループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
注: Qt Quick Controlsでは 、MenuItem はAbstractButton から継承されます。一方、StyleKit では、メニュー項目は通常、通常のボタンとは大きく異なるスタイル(フラットで、境界線やドロップシャドウがないなど)が適用されるため、menuItem はabstractButton ではなくcontrol にフォールバックします。
menuItem {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
width: 200
border.width: 0
}
indicator {
color: "transparent"
border.width: 0
foreground {
image.color: palette.accent
alignment: Qt.AlignCenter
}
first {
alignment: Qt.AlignLeft
foreground.image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
}
second {
alignment: Qt.AlignRight
foreground.image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
}
}
hovered.background.color: "#c0c0c0"
}menuSeparator : ControlStyle
MenuSeparator のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
menuSeparator {
background.visible: false
indicator {
width: 188
height: 1
border.width: 0
color: "#c0c0c0"
foreground.visible: false
}
}page : ControlStyle
Page のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、pane にフォールバックします。
なお、Page のheader およびfooter は、通常、アプリケーションによってToolBar またはTabBar に設定されており、それらのコントロールは個別にスタイルが適用されます。Page 内でToolBar を使用する際に別のスタイルを適用するには、StyleVariation を使用してください:
page {
background {
color: "white"
border.width: 0
}
variations: StyleVariation {
toolBar.background.color: "cornflowerblue"
toolButton.background.color: "skyblue"
toolButton.background.border.color: "aliceblue"
}
}pageIndicator : ControlStyle
PageIndicator のスタイル設定用のグループ化プロパティ。
設定されていないプロパティは、control にフォールバックします。
pageIndicator {
background.visible: false
indicator {
width: 5
height: 5
radius: 255
border.width: 0
color: "black"
opacity: 0.45
foreground.visible: false
}
hovered.indicator {
width: 6
height: 6
opacity: 0.7
}
pressed.indicator {
width: 4
height: 4
}
checked.indicator {
width: 7
height: 7
}
checked.hovered.indicator {
width: 8
height: 8
opacity: 0.7
}
}pane : ControlStyle
Pane のスタイリング用にグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
pane {
background {
width: 200
height: 200
color: "white"
}
}popup : ControlStyle
Popup のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
popup {
background {
color: "white"
border.width: 1
border.color: "darkslategray"
radius: 4
}
}progressBar : ControlStyle
ProgressBar のスタイリング用のグループ化されたプロパティ。プログレスバーの場合、溝(groove)は indicator を通じてスタイリングされ、進行状況のトラック(progress track)は indicator の前景色を通じてスタイリングされます。
設定されていないプロパティは、control にフォールバックします。
progressBar {
// Hide the background; show only the progress bar
background.visible: false
indicator {
width: 150
height: 8
radius: 4
color: "#e0e0e0"
foreground {
// Set margins to add some space between the progress track and the groove
margins: 2
color: palette.accent
radius: 4
}
}
}StyleKit には、プログレスバーの不確定なアニメーションをスタイリングするための専用のプロパティは用意されていません。アニメーションを変更するには、代わりにカスタムインジケーターのフォアグラウンド `delegate ` を実装する必要があります。
progressBar {
indicator {
width: 150
height: 8
foreground {
delegate: StyledItem {
// Draw a pulsating progress track when in indeterminate mode, and a normal track otherwise
width: control.indeterminate ? parent.width : parent.width * control.visualPosition
height: parent.height
opacity: control.indeterminate ? 0.1 : 1.0
SequentialAnimation on opacity {
running: control.indeterminate
loops: Animation.Infinite
NumberAnimation { from: 0.1; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
NumberAnimation { from: 1.0; to: 0.1; duration: 500; easing.type: Easing.InOutQuad }
}
}
}
}
}radioButton : ControlStyle
RadioButton のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
radioButton {
// Hide the button background; show only the indicator and text
background.visible: false
indicator {
// Make the indicator circular
radius: 255
foreground {
// The foreground circle is what shows the checked state, so we make
// it a bit smaller than the outer circle by setting margins
margins: 4
radius: 255
// Hide the foreground circle when the radio button is not checked
visible: false
}
}
// Show the foreground circle when the radio button is checked
checked.indicator.foreground.visible: true
}radioDelegate : ControlStyle
RadioDelegate のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、itemDelegate にフォールバックします。
radioDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
indicator {
radius: 255
foreground {
margins: 4
visible: false
radius: 255
color: palette.accent
}
}
hovered.background.color: "#f0f0f0"
checked.indicator.foreground.visible: true
}roundButton : ControlStyle
RoundButton のスタイリング用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
roundButton {
background.radius: 255
text.alignment: Qt.AlignVCenter | Qt.AlignHCenter
}scrollBar : ControlStyle
ScrollBar のスタイリング用のグループ化プロパティです。溝のスタイリングはbackground を通じて行われ、取っ手のスタイリングはindicator を通じて行われます。
設定されていないプロパティは、control にフォールバックします。
scrollBar {
padding: 0
background {
// Set the groove size and color
width: 10
height: 10
color: "white"
}
indicator {
radius: 255
fillWidth: true
width: 10
height: 10
color: "#c0c0c0"
// The indicator is so simple that it doesn't need a foreground
foreground.visible: false
}
vertical {
indicator {
// In vertical mode, the indicator should stretch vertically
// to fill the available height rather than the available width.
fillWidth: false
fillHeight: true
}
}
}scrollIndicator : ControlStyle
ScrollIndicator のスタイル設定用のグループ化されたプロパティです。溝のスタイルはbackground を通じて、取っ手のスタイルはindicator を通じて設定されます。
設定されていないプロパティは、control にフォールバックします。
scrollIndicator {
// A scroll indicator typically has no groove, just a sliding
// indicator. So hide the background, since it represents the groove.
background.visible: false
indicator {
fillWidth: true
width: 5
height: 5
border.width: 0
color: "cornflowerblue"
// The indicator is so simple that it doesn't need a foreground
foreground.visible: false
}
vertical {
indicator {
// In vertical mode, the indicator should stretch vertically
// to fill the available height rather than the available width.
fillWidth: false
fillHeight: true
}
}
}scrollView : ControlStyle
ScrollView のスタイル設定用のグループ化されたプロパティ。
ScrollView それ自体には、スタイルを設定できる視覚的なデリゲートはありません。そのスクロールバーは、scrollBar プロパティを通じて個別にスタイルを設定できます。ただし、padding を使用することで、スクロールバーとコンテンツ領域の間のスペースを制御できます。
設定されていないプロパティは、control にフォールバックします。
scrollView {
// Add some space between the scroll bars and the content area
padding: 2
// For the sake of the example, style the scroll bars in a ScrollView
// differently from the default scroll bars by using a StyleVariation.
variations: StyleVariation {
scrollBar.indicator.color: "cornflowerblue"
}
}searchField : ControlStyle
SearchField のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
searchField {
// Center the text between the buttons
text.padding: 5
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
text.color: "black"
background.width: 200
indicator {
color: "transparent"
border.width: 0
foreground{
alignment: Qt.AlignCenter
}
// Place the search and clear buttons on the left and right side of the control
// search button
first {
alignment: Qt.AlignLeft
image.color: "black"
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/search-magnifier.png"
}
// clear button
second {
alignment: Qt.AlignRight
image.color: "black"
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/close_circle.png"
}
}
}slider : ControlStyle
Slider のスタイリング用のグループ化されたプロパティです。スライダーの場合、溝(groove)のスタイリングは indicator を通じて行われ、進行状況トラック(progress track)のスタイリングは indicator の foreground を通じて行われます。
設定されていないプロパティは、control にフォールバックします。
縦型スライダーの場合は、以下のスニペットに示すように、関連するデリゲートの `width ` と `height ` を入れ替え、コントロールの高さが幅よりも大きくなるようにしてください。
slider {
background {
// The background is hidden, but its implicit size still
// determines the overall implicit size of the control.
visible: false
width: 150
height: 50
}
indicator {
// The groove of the slider should fill out the entire width of the control
fillWidth: true
height: 8
radius: 255
color: "#e0e0e0"
foreground {
radius: 255
color: palette.accent
}
}
handle {
width: 24
height: 24
radius: 255
color: "white"
border.color: "#c0c0c0"
}
vertical {
// Transpose relevant geometry
background {
width: 50
height: 150
}
indicator {
fillWidth: false
fillHeight: true
width: 8
}
}
}spinBox : ControlStyle
SpinBox のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
spinBox {
// Center the text between the up/down buttons
text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
indicator {
color: "transparent"
border.width: 0
foreground {
image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
image.color: "black"
alignment: Qt.AlignCenter
}
// Place the down and up buttons on the left and right side of the control
// up button
first {
alignment: Qt.AlignRight
foreground.rotation: -90
}
// down button
second {
alignment: Qt.AlignLeft
foreground.rotation: 90
}
}
}注: 現在、上下ボタンの配置はコントロールの左側または右側のみ可能で 、上下に重ねて配置することはできません。
swipeDelegate : ControlStyle
SwipeDelegate のスタイリング用のグループ化されたプロパティ。
設定されていないプロパティは、itemDelegate にフォールバックします。
swipeDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
hovered.background.color: "#f0f0f0"
}switchControl : ControlStyle
Switch のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
switchControl {
// For a switch control, we typically don't want a background, only an indicator with a handle
background.visible: false
indicator {
radius: 12
foreground {
// Add some space between the indicator and the foreground track
margins: 2
radius: 12
// The foreground track should only be visible when the switch is checked
visible: false
}
}
checked.indicator.foreground.visible: true
handle {
// Add some space between the handle and the indicator
leftMargin: 2
rightMargin: 2
width: 20
height: 20
radius: 255
color: "white"
}
}switchDelegate : ControlStyle
SwitchDelegate のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、itemDelegate にフォールバックします。
switchDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
indicator {
radius: 12
foreground {
// Add some space between the indicator and the foreground track
margins: 2
radius: 12
// The foreground track should only be visible when the switch is checked
visible: false
}
}
handle {
// Add some space between the handle and the indicator
leftMargin: 2
rightMargin: 2
width: 20
height: 20
radius: 255
color: "white"
}
hovered.background.color: "#f0f0f0"
checked.indicator.foreground.visible: true
}tabBar : ControlStyle
TabBar のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、pane にフォールバックします。
tabBar {
padding: 0
spacing: -1 // let tab buttons overlap slightly
background {
color: "white"
border.width: 0
}
}tabButton : ControlStyle
TabButton のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
tabButton {
background {
radius: 0
topLeftRadius: 4
topRightRadius: 4
color: "#e8e8e8"
}
checked.background.color: "white"
}textArea : ControlStyle
TextArea のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、textInput にフォールバックします。
textArea {
// Add some space between the text and the border of the text area
padding: 8
text.color: "black"
background {
color: "white"
border.color: "#c0c0c0"
}
focused.background.border.color: palette.accent
}textField : ControlStyle
TextField のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、textInput にフォールバックします。
textField {
// Add some space between the text and the border of the text field
padding: 8
text.alignment: Qt.AlignVCenter
background {
width: 150
color: "white"
border.color: "#c0c0c0"
}
focused.background.border.color: palette.accent
}textInput : ControlStyle
TextField やTextArea など、すべてのテキスト入力コントロールのスタイルを設定するためのグループ化されたプロパティです。
設定されていないプロパティは、control にフォールバックします。
textInput {
// Add some space between the text and the border of the text input
padding: 8
text.color: "black"
background {
color: "white"
border.width: 1
border.color: "#c0c0c0"
}
}toolBar : ControlStyle
ToolBar のスタイリング用グループ化プロパティ。
設定されていないプロパティは、pane にフォールバックします。
toolBar {
spacing: 2
background {
radius: 0
height: 40
border.width: 1
}
}toolButton : ControlStyle
ToolButton のスタイル設定用のグループ化プロパティ。
設定されていないプロパティは、abstractButton にフォールバックします。
toolButton {
background.radius: 0
}toolSeparator : ControlStyle
ToolSeparator のスタイル設定用のグループ化されたプロパティ。
設定されていないプロパティは、control にフォールバックします。
垂直セパレータの場合は、以下のスニペットに示すように、関連するデリゲートの `width ` と `height ` を入れ替えて、コントロールの高さが幅よりも大きくなるようにしてください。
toolSeparator {
background {
// The background is hidden, but its implicit size still
// determines the overall implicit size of the control.
visible: false
width: 10
height: 10
}
indicator {
width: 30
height: 1
border.width: 0
color: "#c0c0c0"
alignment: Qt.AlignCenter
foreground.visible: false
}
vertical {
indicator {
width: 1
height: 30
}
}
}メソッドのドキュメント
ControlStyle getControlStyle(controlType)
指定されたcontrolType に対するControlStyle を返します。ただし、その型に対してControlStyle が定義されていない場合は、null を返します。
controlType 引数は、StyleReader.controlType に記載されている組み込み型のいずれか、またはCustomControl のcontrolType のいずれかです。
この関数は、例えば、実行時にCustomControl のスタイルのプロパティを読み書きするために使用できます:
Style {
id: myStyle
property int customButtonType: 0
CustomControl {
controlType: myStyle.customButtonType
background.color: "green"
}
}
function changeButtonColor() {
let customControlStyle = myStyle.getControlStyle(style.customButtonType)
customControlStyle.background.color = "yellowgreen"
// You can also access the style definition in the theme, if it has one
// myStyle.theme.getControlStyle(StyleReader.Button).padding = 10
}controlType が組み込み型(StyleReader.Button など)である場合、例えばmyStyle.button やmyStyle.getControlStyle(StyleReader.Button) を使用してControlStyle を取得することは、ほぼ同等です。違いは、前者はControlStyle がまだ定義されていない場合に遅延生成を行うのに対し、後者は代わりにnull を返す点です。つまり、例えばmyStyle.button.padding = 10 は常に安全ですが、myStyle.getControlStyle(StyleReader.Button).padding = 10 はmyStyle.button がStyle で定義されていない場合に失敗します。
CustomControl およびStyleReaderも参照してください 。
© 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.