QML使用Material风格

1、在pro里加入

QT += quickcontrols2

2、在main.cpp里加入

QQuickStyle::setStyle("Material");

3、在qml里

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
ApplicationWindow {
    visible: true
    width: 480
    height: 360
    title: qsTr("Material Style")
    Material.theme: Material.Grey
    Material.accent: Material.color("red")
    Column {
        anchors.centerIn: parent
        RadioButton { text: qsTr("Small") }
        RadioButton { text: qsTr("Medium");  checked: true }
        RadioButton { text: qsTr("Large") }
    }
    Button {
        text: qsTr("Button")
        highlighted: true
        Material.background: Material.Teal
        anchors.horizontalCenter: parent.horizontalCenter
    }
}

 参考:https://uzshare.com/view/819927

猜你喜欢

转载自www.cnblogs.com/judes/p/12744729.html