C++ 入門指南 4.01
練習 29.2 參考程式 - 練習 QML 的 Button
import QtQuick
import QtQuick.Controls
ApplicationWindow {
width: 200
height: 200
visible: true
title: qsTr("按鈕測試")
Column {
width: 200
height: 200
Row {
width: 200
height: 50
Button {
width: 50
height: 50
text: qsTr("按鈕一")
}
}
Row {
width: 200
height: 50
Rectangle {
width: 50
height: 50
}
Button {
width: 50
height: 50
text: qsTr("按鈕二")
}
}
Row {
width: 200
height: 50
Rectangle {
width: 100
height: 50
}
Button {
width: 50
height: 50
text: qsTr("按鈕三")
}
}
Row {
width: 200
height: 50
Rectangle {
width: 150
height: 50
}
Button {
width: 50
height: 50
text: qsTr("按鈕四")
}
}
}
}
/* 《程式語言教學誌》的範例程式
http://kaiching.org/
檔名:main.qml
功能:示範 Button 型態
作者:張凱慶 */
回到練習題目