Skip to content
KerwinKoo edited this page Dec 27, 2015 · 2 revisions

Qt5.4 QML Button

1.QML 中的 Button 和 QPushButton 类似,用户点击按钮会触发一个 clicked() 信号,在 QML 文档中可以为 clicked() 指定信号处理器,响应用户操作。

2.要使用 Button ,需要引入 import QtQuick.Controls 1.1

代码举例:

import QtQuick 2.0
import QtQuick.Controls 1.1

Rectangle {
    width: 300;
    height: 200;
    Button {
        anchors.centerIn: parent;
        text: "Quit";
        onClicked: Qt.quit();				//处理点击事件
    }
}

[[TOC]]

Clone this wiki locally