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

posted @ 2020-04-21 15:02  朱小勇  阅读(3181)  评论(0编辑  收藏  举报