/usr/share/qt5/doc/qtquickcontrols2/qtquickcontrols2-material.html is in qtquickcontrols2-5-doc-html 5.9.5-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qtquickcontrols2-material.qdoc -->
<title>Material Style | Qt Quick Controls 2 5.9</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.9</td><td ><a href="qtquickcontrols2-index.html">Qt Quick Controls 2</a></td><td >Material Style</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.5 Reference Documentation</td>
</tr></table>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#attached-properties">Attached Properties</a></li>
<li class="level1"><a href="#attached-methods">Attached Methods</a></li>
<li class="level1"><a href="#detailed-description">Detailed Description</a></li>
<li class="level2"><a href="#customization">Customization</a></li>
<li class="level2"><a href="#dependency">Dependency</a></li>
<li class="level2"><a href="#pre-defined-material-colors">Pre-defined Material Colors</a></li>
<li class="level2"><a href="#pre-defined-shades">Pre-defined Shades</a></li>
<li class="level1"><a href="#attached-property-documentation">Attached Property Documentation</a></li>
<li class="level1"><a href="#attached-method-documentation">Attached Method Documentation</a></li>
<li class="level1"><a href="#related-information">Related Information</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Material Style</h1>
<span class="subtitle"></span>
<!-- $$$qtquickcontrols2-material.html-description -->
<div class="descr"> <a name="details"></a>
<p>The Material Style is based on the Google Material Design Guidelines. <a href="qtquickcontrols2-material.html#detailed-desc-material">More...</a></p>
<table class="alignedsummary"><tbody><tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick.Controls.Material 2.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.7</td></tr></tbody></table><a name="attached-properties"></a>
<h2 id="attached-properties">Attached Properties</h2>
<ul>
<li><a href="qtquickcontrols2-material.html#material-accent-attached-prop"><b>accent</b></a> : color</li>
<li><a href="qtquickcontrols2-material.html#material-background-attached-prop"><b>background</b></a> : color</li>
<li><a href="qtquickcontrols2-material.html#material-elevation-attached-prop"><b>elevation</b></a> : int</li>
<li><a href="qtquickcontrols2-material.html#material-foreground-attached-prop"><b>foreground</b></a> : color</li>
<li><a href="qtquickcontrols2-material.html#material-primary-attached-prop"><b>primary</b></a> : color</li>
<li><a href="qtquickcontrols2-material.html#material-theme-attached-prop"><b>theme</b></a> : enumeration</li>
</ul>
<a name="attached-methods"></a>
<h2 id="attached-methods">Attached Methods</h2>
<ul>
<li>color <a href="qtquickcontrols2-material.html#material-color-attached-method"><b>color</b></a>(enumeration predefined, enumeration shade)</li>
</ul>
<a name="detailed-description"></a>
<h2 id="detailed-description">Detailed Description</h2>
<a name="detailed-desc-material"></a><p>The Material style is based on the <a href="https://www.google.com/design/spec/material-design/introduction.html">Google Material Design Guidelines</a>. It allows for a unified experience across platforms and device sizes.</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-light.png" alt="" /></p><p class="figCaption">The Material style in light theme</p>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-dark.png" alt="" /></p><p class="figCaption">The Material style in dark theme</p>
</td></tr>
</table></div>
<p>To run an application with the Material style, see <a href="qtquickcontrols2-styles.html#using-styles-in-qt-quick-controls-2">Using Styles in Qt Quick Controls 2</a>.</p>
<p><b>Note: </b>The Material style is not a native Android style. The Material style is a 100% cross-platform Qt Quick Controls 2 style implementation that follows the Google Material Design Guidelines. The style runs on any platform, and looks more or less identical everywhere. Minor differences may occur due to differences in available system fonts and font rendering engines.</p><a name="customization"></a>
<h3 >Customization</h3>
<p>The Material style allows customizing five attributes, <a href="qtquickcontrols2-material.html#material-theme-attached-prop">theme</a>, <a href="qtquickcontrols2-material.html#material-primary-attached-prop">primary</a>, <a href="qtquickcontrols2-material.html#material-accent-attached-prop">accent</a>, <a href="qtquickcontrols2-material.html#material-foreground-attached-prop">foreground</a>, and <a href="qtquickcontrols2-material.html#material-background-attached-prop">background</a>.</p>
<p class="centerAlign"><img src="images/qtquickcontrols2-material-attributes.png" alt="" /></p><p>All attributes can be specified for any window or item, and they automatically propagate to children in the same manner as <a href="qml-qtquick-controls2-control.html#font-prop">fonts</a>. In the following example, the window and all three radio buttons appear in the dark theme using a purple accent color:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
<span class="type"><a href="qml-qtquick-controls2-applicationwindow.html">ApplicationWindow</a></span> {
<span class="name">visible</span>: <span class="number">true</span>
<span class="name">Material</span>.theme: <span class="name">Material</span>.<span class="name">Dark</span>
<span class="name">Material</span>.accent: <span class="name">Material</span>.<span class="name">Purple</span>
<span class="type"><a href="../qtquick/qml-qtquick-column.html">Column</a></span> {
<span class="name">anchors</span>.centerIn: <span class="name">parent</span>
<span class="type"><a href="qml-qtquick-controls2-radiobutton.html">RadioButton</a></span> { <span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Small"</span>) }
<span class="type"><a href="qml-qtquick-controls2-radiobutton.html">RadioButton</a></span> { <span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Medium"</span>); <span class="name">checked</span>: <span class="number">true</span> }
<span class="type"><a href="qml-qtquick-controls2-radiobutton.html">RadioButton</a></span> { <span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Large"</span>) }
}
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-purple.png" alt="" /></p></td></tr>
</table></div>
<p>In addition to specifying the attributes in QML, it is also possible to specify them via environment variables or in a configuration file. Attributes specified in QML take precedence over all other methods.</p>
<a name="configuration-file"></a>
<h4 >Configuration File</h4>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th >Variable</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>Theme</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-theme-attached-prop">Material theme</a>. The value can be one of the available themes, for example <code>"Dark"</code>.</td></tr>
<tr valign="top" class="even"><td ><code>Accent</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-accent-attached-prop">Material accent color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, but it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Teal"</code>.</td></tr>
<tr valign="top" class="odd"><td ><code>Primary</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-primary-attached-prop">Material primary color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, but it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"BlueGrey"</code>.</td></tr>
<tr valign="top" class="even"><td ><code>Foreground</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-foreground-attached-prop">Material foreground color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, or one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Brown"</code>.</td></tr>
<tr valign="top" class="odd"><td ><code>Background</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-background-attached-prop">Material background color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, or one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Grey"</code>.</td></tr>
</table></div>
<p>See <a href="qtquickcontrols2-configuration.html">Qt Quick Controls 2 Configuration File</a> for more details about the configuration file.</p>
<a name="environment-variables"></a>
<h4 >Environment Variables</h4>
<div class="table"><table class="generic">
<thead><tr class="qt-style"><th >Variable</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td ><code>QT_QUICK_CONTROLS_MATERIAL_THEME</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-theme-attached-prop">Material theme</a>. The value can be one of the available themes, for example <code>"Dark"</code>.</td></tr>
<tr valign="top" class="even"><td ><code>QT_QUICK_CONTROLS_MATERIAL_ACCENT</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-accent-attached-prop">Material accent color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, but it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Teal"</code>.</td></tr>
<tr valign="top" class="odd"><td ><code>QT_QUICK_CONTROLS_MATERIAL_PRIMARY</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-primary-attached-prop">Material primary color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, but it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"BlueGrey"</code>.</td></tr>
<tr valign="top" class="even"><td ><code>QT_QUICK_CONTROLS_MATERIAL_FOREGROUND</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-foreground-attached-prop">Material foreground color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, or one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Brown"</code>.</td></tr>
<tr valign="top" class="odd"><td ><code>QT_QUICK_CONTROLS_MATERIAL_BACKGROUND</code></td><td >Specifies the default <a href="qtquickcontrols2-material.html#material-background-attached-prop">Material background color</a>. The value can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, or one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a>, for example <code>"Grey"</code>.</td></tr>
</table></div>
<p>See <a href="qtquickcontrols2-environment.html">Supported Environment Variables in Qt Quick Controls 2</a> for the full list of supported environment variables.</p>
<a name="dependency"></a>
<h3 >Dependency</h3>
<p>The Material style must be separately imported to gain access to the attributes that are specific to the Material style. It should be noted that regardless of the references to the Material style, the same application code runs with any other style. Material-specific attributes only have an effect when the application is run with the Material style.</p>
<p>If the Material style is imported in a QML file that is always loaded, the Material style must be deployed with the application in order to be able to run the application regardless of which style the application is run with. By using <a href="qtquickcontrols2-fileselectors.html">file selectors</a>, style-specific tweaks can be applied without creating a hard dependency to a style.</p>
<a name="pre-defined-material-colors"></a>
<h3 >Pre-defined Material Colors</h3>
<p>Even though primary and accent can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, it is recommended to use one of the pre-defined colors that have been designed to work well with the rest of the Material style palette:</p>
<p>Available pre-defined colors:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="even"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>Material.Red</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#F44336;">#F44336 </div></td></tr>
<tr><td class="topAlign"><code>Material.Pink</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#E91E63;">#E91E63 (default accent)</div></td></tr>
<tr><td class="topAlign"><code>Material.Purple</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#9C27B0;">#9C27B0 </div></td></tr>
<tr><td class="topAlign"><code>Material.DeepPurple</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#673AB7;">#673AB7 </div></td></tr>
<tr><td class="topAlign"><code>Material.Indigo</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#3F51B5;">#3F51B5 (default primary)</div></td></tr>
<tr><td class="topAlign"><code>Material.Blue</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#2196F3;">#2196F3 </div></td></tr>
<tr><td class="topAlign"><code>Material.LightBlue</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#03A9F4;">#03A9F4 </div></td></tr>
<tr><td class="topAlign"><code>Material.Cyan</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#00BCD4;">#00BCD4 </div></td></tr>
<tr><td class="topAlign"><code>Material.Teal</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#009688;">#009688 </div></td></tr>
<tr><td class="topAlign"><code>Material.Green</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#4CAF50;">#4CAF50 </div></td></tr>
<tr><td class="topAlign"><code>Material.LightGreen</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#8BC34A;">#8BC34A </div></td></tr>
<tr><td class="topAlign"><code>Material.Lime</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#CDDC39;">#CDDC39 </div></td></tr>
<tr><td class="topAlign"><code>Material.Yellow</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFEB3B;">#FFEB3B </div></td></tr>
<tr><td class="topAlign"><code>Material.Amber</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFC107;">#FFC107 </div></td></tr>
<tr><td class="topAlign"><code>Material.Orange</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FF9800;">#FF9800 </div></td></tr>
<tr><td class="topAlign"><code>Material.DeepOrange</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FF5722;">#FF5722 </div></td></tr>
<tr><td class="topAlign"><code>Material.Brown</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#795548;">#795548 </div></td></tr>
<tr><td class="topAlign"><code>Material.Grey</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#9E9E9E;">#9E9E9E </div></td></tr>
<tr><td class="topAlign"><code>Material.BlueGrey</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#607D8B;">#607D8B </div></td></tr>
</table></div>
<p>When the dark theme is in use, different <a href="qtquickcontrols2-material.html#pre-defined-shades">shades</a> of the pre-defined colors are used by default:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>Material.Red</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#EF9A9A;">#EF9A9A </div></td></tr>
<tr><td class="topAlign"><code>Material.Pink</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#F48FB1;">#F48FB1 (default accent)</div></td></tr>
<tr><td class="topAlign"><code>Material.Purple</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#CE93D8;">#CE93D8 </div></td></tr>
<tr><td class="topAlign"><code>Material.DeepPurple</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#B39DDB;">#B39DDB </div></td></tr>
<tr><td class="topAlign"><code>Material.Indigo</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#9FA8DA;">#9FA8DA (default primary)</div></td></tr>
<tr><td class="topAlign"><code>Material.Blue</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#90CAF9;">#90CAF9 </div></td></tr>
<tr><td class="topAlign"><code>Material.LightBlue</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#81D4FA;">#81D4FA </div></td></tr>
<tr><td class="topAlign"><code>Material.Cyan</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#80DEEA;">#80DEEA </div></td></tr>
<tr><td class="topAlign"><code>Material.Teal</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#80CBC4;">#80CBC4 </div></td></tr>
<tr><td class="topAlign"><code>Material.Green</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#A5D6A7;">#A5D6A7 </div></td></tr>
<tr><td class="topAlign"><code>Material.LightGreen</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#C5E1A5;">#C5E1A5 </div></td></tr>
<tr><td class="topAlign"><code>Material.Lime</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#E6EE9C;">#E6EE9C </div></td></tr>
<tr><td class="topAlign"><code>Material.Yellow</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFF59D;">#FFF59D </div></td></tr>
<tr><td class="topAlign"><code>Material.Amber</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFE082;">#FFE082 </div></td></tr>
<tr><td class="topAlign"><code>Material.Orange</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFCC80;">#FFCC80 </div></td></tr>
<tr><td class="topAlign"><code>Material.DeepOrange</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#FFAB91;">#FFAB91 </div></td></tr>
<tr><td class="topAlign"><code>Material.Brown</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#BCAAA4;">#BCAAA4 </div></td></tr>
<tr><td class="topAlign"><code>Material.Grey</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#EEEEEE;">#EEEEEE </div></td></tr>
<tr><td class="topAlign"><code>Material.BlueGrey</code></td><td class="topAlign"><div style="padding:10px;color:#fff;background:#B0BEC5;">#B0BEC5 </div></td></tr>
</table></div>
<a name="pre-defined-shades"></a>
<h3 >Pre-defined Shades</h3>
<p>There are several different <a href="https://material.google.com/style/color.html#color-color-palette">shades</a> of each <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined color</a> that can be passed to the <a href="qtquickcontrols2-material.html#material-color-attached-method">Material.color()</a> function:</p>
<div class="table"><table class="valuelist"><tr><th class="tblConst">Constant</th><th class="tblVal">Value</th></tr>
<tr><td class="topAlign"><code>Material.Shade50</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade100</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade200</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade300</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade400</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade500</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade600</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade700</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade800</code></td></tr>
<tr><td class="topAlign"><code>Material.Shade900</code></td></tr>
<tr><td class="topAlign"><code>Material.ShadeA100</code></td></tr>
<tr><td class="topAlign"><code>Material.ShadeA200</code></td></tr>
<tr><td class="topAlign"><code>Material.ShadeA400</code></td></tr>
<tr><td class="topAlign"><code>Material.ShadeA700</code></td></tr>
</table></div>
<p><b>See also</b> <a href="qtquickcontrols2-default.html">Default Style</a>, <a href="qtquickcontrols2-universal.html">Universal Style</a></p>
<a name="attached-property-documentation"></a>
<h2 id="attached-property-documentation">Attached Property Documentation</h2>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-accent-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.accent</span> : <span class="type">color</span></p></td></tr></tbody></table></div><a name="material-accent-attached-prop"></a><p>This attached property holds the accent color of the theme. The property can be attached to any window or item. The value is propagated to children.</p>
<p>The default value is <code>Material.Pink</code>.</p>
<p>In the following example, the accent color of the highlighted button is changed to <code>Material.Orange</code>:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-button.html">Button</a></span> {
<span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Button"</span>)
<span class="name">highlighted</span>: <span class="number">true</span>
<span class="name">Material</span>.accent: <span class="name">Material</span>.<span class="name">Orange</span>
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-accent.png" alt="" /></p></td></tr>
</table></div>
<p><b>Note: </b>Even though the accent can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a> that have been designed to work well with the rest of the Material style palette.</p><p><br />
</p>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-background-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.background</span> : <span class="type">color</span></p></td></tr></tbody></table></div><a name="material-background-attached-prop"></a><p>This attached property holds the background color of the theme. The property can be attached to any window or item. The value is propagated to children.</p>
<p>The default value is theme-specific (light or dark).</p>
<p>In the following example, the background color of the button is changed to <code>Material.Teal</code>:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-button.html">Button</a></span> {
<span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Button"</span>)
<span class="name">highlighted</span>: <span class="number">true</span>
<span class="name">Material</span>.background: <span class="name">Material</span>.<span class="name">Teal</span>
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-background.png" alt="" /></p></td></tr>
</table></div>
<p><br />
</p>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-elevation-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.elevation</span> : <span class="type">int</span></p></td></tr></tbody></table></div><a name="material-elevation-attached-prop"></a><p>This attached property holds the elevation of the control. The higher the elevation, the deeper the shadow. The property can be attached to any control, but not all controls visualize elevation.</p>
<p>The default value is control-specific.</p>
<p>In the following example, the elevation of the pane is set to <code>6</code> in order to achieve the look of an <a href="https://material.google.com/components/cards.html">elevated card</a>:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-pane.html">Pane</a></span> {
<span class="name">width</span>: <span class="number">120</span>
<span class="name">height</span>: <span class="number">120</span>
<span class="name">Material</span>.elevation: <span class="number">6</span>
<span class="type"><a href="qml-qtquick-controls2-label.html">Label</a></span> {
<span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"I'm a card!"</span>)
<span class="name">anchors</span>.centerIn: <span class="name">parent</span>
}
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-elevation.png" alt="" /></p></td></tr>
</table></div>
<p><br />
</p>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-foreground-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.foreground</span> : <span class="type">color</span></p></td></tr></tbody></table></div><a name="material-foreground-attached-prop"></a><p>This attached property holds the foreground color of the theme. The property can be attached to any window or item. The value is propagated to children.</p>
<p>The default value is theme-specific (light or dark).</p>
<p>In the following example, the foreground color of the button is set to <code>Material.Pink</code>:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-button.html">Button</a></span> {
<span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Button"</span>)
<span class="name">Material</span>.foreground: <span class="name">Material</span>.<span class="name">Pink</span>
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-foreground.png" alt="" /></p></td></tr>
</table></div>
<p><br />
</p>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-primary-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.primary</span> : <span class="type">color</span></p></td></tr></tbody></table></div><a name="material-primary-attached-prop"></a><p>This attached property holds the primary color of the theme. The property can be attached to any window or item. The value is propagated to children.</p>
<p>The primary color is used as the background color of <a href="qml-qtquick-controls2-toolbar.html">ToolBar</a> by default.</p>
<p>The default value is <code>Material.Indigo</code>.</p>
<p><b>Note: </b>Even though the primary can be any <a href="../qtquick/qml-color.html#colorbasictypedocs">color</a>, it is recommended to use one of the <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material colors</a> that have been designed to work well with the rest of the Material style palette.</p><p><br />
</p>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-theme-attached-prop"><td class="tblQmlPropNode"><p><span class="name">Material.theme</span> : <span class="type">enumeration</span></p></td></tr></tbody></table></div><a name="material-theme-attached-prop"></a><p>This attached property holds whether the theme is light or dark. The property can be attached to any window or item. The value is propagated to children.</p>
<p>Available themes:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="even"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>Material.Light</code></td><td class="topAlign">Light theme (default)</td></tr>
<tr><td class="topAlign"><code>Material.Dark</code></td><td class="topAlign">Dark theme</td></tr>
<tr><td class="topAlign"><code>Material.System</code></td><td class="topAlign">System theme</td></tr>
</table></div>
<p>Setting the theme to <code>System</code> chooses either the light or dark theme based on the system theme colors. However, when reading the value of the theme property, the value is never <code>System</code>, but the actual theme.</p>
<p>In the following example, the theme for both the pane and the button is set to <code>Material.Dark</code>:</p>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><pre class="qml">
<span class="type"><a href="qml-qtquick-controls2-pane.html">Pane</a></span> {
<span class="name">Material</span>.theme: <span class="name">Material</span>.<span class="name">Dark</span>
<span class="type"><a href="qml-qtquick-controls2-button.html">Button</a></span> {
<span class="name">text</span>: <span class="name">qsTr</span>(<span class="string">"Button"</span>)
}
}
</pre>
</td><td ><p class="centerAlign"><img src="images/qtquickcontrols2-material-theme.png" alt="" /></p></td></tr>
</table></div>
<p><br />
</p>
<a name="attached-method-documentation"></a>
<h2 id="attached-method-documentation">Attached Method Documentation</h2>
<div class="qmlproto"><table class="qmlname"><tbody><tr valign="top" class="odd" id="material-color-attached-method"><td class="tblQmlFuncNode"><p><span class="type">color</span> <span class="name">color</span>(<span class= type>enumeration</span> <i>predefined</i>, <span class= type>enumeration</span> <i>shade</i>)</p></td></tr></tbody></table></div><a name="material-color-attached-method"></a><p>This attached method returns the effective color value of the specified <a href="qtquickcontrols2-material.html#pre-defined-material-colors">pre-defined Material color</a> combined with the given <a href="qtquickcontrols2-material.html#pre-defined-shades">shade</a>. If omitted, the shade argument defaults to <code>Material.Shade500</code>.</p>
<pre class="qml">
<span class="type"><a href="../qtquick/qml-qtquick-rectangle.html">Rectangle</a></span> {
<span class="name">color</span>: <span class="name">Material</span>.<span class="name">color</span>(<span class="name">Material</span>.<span class="name">Red</span>)
}
</pre>
<p><br />
</p>
<a name="related-information"></a>
<h2 id="related-information">Related Information</h2>
<ul>
<li><a href="qtquickcontrols2-styles.html">Styling Qt Quick Controls 2</a></li>
</ul>
</div>
<!-- @@@qtquickcontrols2-material.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> 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. </p>
</div>
</body>
</html>
|