/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:FDL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free ** Documentation License version 1.3 as published by the Free Software ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements ** will be met: http://www.gnu.org/copyleft/fdl.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \page qtquickcontrols2-material.html \title Material Style The Material Style is based on the Google Material Design Guidelines. \l{detailed-desc-material}{More...} \styleimport {QtQuick.Controls.Material 2.1} {Qt 5.7} \section1 Attached Properties \list \li \l {accent-attached-prop}{\b accent} : color \li \l {background-attached-prop}{\b background} : color \li \l {foreground-attached-prop}{\b foreground} : color \li \l {primary-attached-prop}{\b primary} : color \li \l {theme-attached-prop}{\b theme} : enumeration \endlist \section1 Attached Methods \list \li color \l {color-attached-method}{\b color}(enumeration predefined) \endlist \section1 Detailed Description \target detailed-desc-material The Material style is based on the \l {https://www.google.com/design/spec/material-design/introduction.html} {Google Material Design Guidelines}. It allows for a unified experience across platforms and device sizes. \image qtquickcontrols2-material.png \caption The Material style in light and dark themes \note 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. \section2 Customization The Material style allows customizing five attributes, \l {theme-attached-prop}{theme}, \l {primary-attached-prop}{primary}, \l {accent-attached-prop}{accent}, \l {foreground-attached-prop}{foreground}, and \l {background-attached-prop}{background}. \image qtquickcontrols2-material-attributes.png The following example illustrates how to create a red \e stop button with light text: \table \row \li \qml import QtQuick 2.0 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 Button { text: "Stop" highlighted: true Material.accent: Material.Red Material.theme: Material.Dark } \endqml \li \image qtquickcontrols2-material-button.png \endtable All attributes can be specified for any window or item, and they automatically propagate to children in the same manner as \l {Control::font}{fonts}. In the following example, the window and all three radio buttons appear in the dark theme using a purple accent color: \table \row \li \qml import QtQuick 2.0 import QtQuick.Controls 2.0 import QtQuick.Controls.Material 2.0 ApplicationWindow { visible: true Material.theme: Material.Dark Material.accent: Material.Purple Column { anchors.centerIn: parent RadioButton { text: qsTr("Small") } RadioButton { text: qsTr("Medium"); checked: true } RadioButton { text: qsTr("Large") } } } \endqml \li \image qtquickcontrols2-material-dark.png \endtable In addition to specifying the attributes in QML, it is also possible to specify them via environment variables or in a \l {qtquickcontrols2-conf} {configuration file}. \section3 Environment Variables \table \header \li Variable \li Description \row \li \c QT_QUICK_CONTROLS_MATERIAL_THEME \li The value can be one of the available \l {theme-attached-prop}{themes}, for example \c "Dark". \row \li \c QT_QUICK_CONTROLS_MATERIAL_ACCENT \li The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use one of the \l {Pre-defined Colors}{pre-defined colors}, for example for example \c "Teal". \row \li \c QT_QUICK_CONTROLS_MATERIAL_PRIMARY \li The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use one of the \l {Pre-defined Colors}{pre-defined colors}, for example for example \c "BlueGrey". \row \li \c QT_QUICK_CONTROLS_MATERIAL_FOREGROUND \li The value can be any \l {colorbasictypedocs}{color}, or one of the \l {Pre-defined Colors}{pre-defined colors}. \row \li \c QT_QUICK_CONTROLS_MATERIAL_BACKGROUND \li The value can be any \l {colorbasictypedocs}{color}, or one of the \l {Pre-defined Colors}{pre-defined colors}. \endtable \section2 Dependency 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. 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 \l {Using File Selectors with Qt Quick Controls 2}{file selectors}, style-specific tweaks can be applied without creating a hard dependency to a style. \section2 Pre-defined Colors Even though primary and accent can be any \l {colorbasictypedocs}{color}, 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: Available pre-defined colors: \value Material.Red \stylecolor {#F44336} {} \value Material.Pink \stylecolor {#E91E63} {(default accent)} \value Material.Purple \stylecolor {#9C27B0} {} \value Material.DeepPurple \stylecolor {#673AB7} {} \value Material.Indigo \stylecolor {#3F51B5} {(default primary)} \value Material.Blue \stylecolor {#2196F3} {} \value Material.LightBlue \stylecolor {#03A9F4} {} \value Material.Cyan \stylecolor {#00BCD4} {} \value Material.Teal \stylecolor {#009688} {} \value Material.Green \stylecolor {#4CAF50} {} \value Material.LightGreen \stylecolor {#8BC34A} {} \value Material.Lime \stylecolor {#CDDC39} {} \value Material.Yellow \stylecolor {#FFEB3B} {} \value Material.Amber \stylecolor {#FFC107} {} \value Material.Orange \stylecolor {#FF9800} {} \value Material.DeepOrange \stylecolor {#FF5722} {} \value Material.Brown \stylecolor {#795548} {} \value Material.Grey \stylecolor {#9E9E9E} {} \value Material.BlueGrey \stylecolor {#607D8B} {} \b {See also} \l {Default Style}, \l {Universal Style} \section1 Attached Property Documentation \styleproperty {Material.accent} {color} {accent-attached-prop} \target accent-attached-prop 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. The default value is \c Material.Pink. \note Even though the accent can be any \l {colorbasictypedocs}{color}, it is recommended to use one of the \l {pre-defined colors} that have been designed to work well with the rest of the Material style palette. \endstyleproperty \styleproperty {Material.background} {color} {background-attached-prop} \target background-attached-prop 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. The default value is theme-specific (light or dark). \endstyleproperty \styleproperty {Material.foreground} {color} {foreground-attached-prop} \target foreground-attached-prop 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. The default value is theme-specific (light or dark). \endstyleproperty \styleproperty {Material.primary} {color} {primary-attached-prop} \target primary-attached-prop 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. The default value is \c Material.Indigo. \note Even though the primary can be any \l {colorbasictypedocs}{color}, it is recommended to use one of the \l {pre-defined colors} that have been designed to work well with the rest of the Material style palette. \endstyleproperty \styleproperty {Material.theme} {enumeration} {theme-attached-prop} \target theme-attached-prop 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. Available themes: \value Material.Light Light theme (default) \value Material.Dark Dark theme \value Material.System System theme Setting the theme to \c System 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 \c System, but the actual theme. \endstyleproperty \section1 Attached Method Documentation \stylemethod {color} {color} {enumeration} {predefined} {color-attached-method} \target color-attached-method This attached method returns the color value of the specified \l {pre-defined colors} {pre-defined color}. \qml import QtQuick 2.0 import QtQuick.Controls.Material 2.0 Rectangle { color: Material.color(Material.Red) } \endqml \endstylemethod \section1 Related Information \list \li \l{Styling Qt Quick Controls 2} \endlist */