C++ 入門指南 4.01
練習 29.8 參考程式 - 練習設計猜數字遊戲外觀
import QtQuick
import QtQuick.Controls
import io.qt.examples.guesscontroller 1.0
ApplicationWindow {
id: root
width: 200
height: 140
visible: true
title: qsTr("猜數字遊戲")
GuessController {
id: controller
}
Column {
Row {
width: 200
height: 25
TextField {
id: input
width: 200
color: "blue"
placeholderText: qsTr("輸入猜測數字")
text: controller.userInput
onEditingFinished: controller.userInput = text
}
}
Row {
width: 200
height: 20
Text {
id: display
width: 200
text: "提示訊息"
}
}
Row {
width: 200
height: 20
Text {
width: 60
text: "猜測次數:"
}
Text {
id: counter
width: 140
text: "0"
}
}
Row {
width: 200
height: 25
Button {
width: 200
text: "猜測"
}
}
Row {
width: 200
height: 25
Button {
width: 200
text: "新遊戲"
}
}
}
}
/* 《程式語言教學誌》的範例程式
http://kaiching.org/
檔名:main.qml
功能:示範猜數字遊戲的 GUI 外觀
作者:張凱慶 */
回到練習題目