C++ 入門指南 4.01
練習 26.9 參考程式 - 練習 QML 的 SwipeView
import QtQuick
import QtQuick.Controls
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("分頁展示")
SwipeView {
id: view
currentIndex: 0
anchors.fill: parent
Item {
id: firstPage
Text {
font.pointSize: 40
anchors.centerIn: parent
text: "第一頁"
}
}
Item {
id: secondPage
Text {
font.pointSize: 40
anchors.centerIn: parent
text: "第二頁"
}
}
Item {
id: thirdPage
Text {
font.pointSize: 40
anchors.centerIn: parent
text: "第三頁"
}
}
}
PageIndicator {
id: indicator
count: view.count
currentIndex: view.currentIndex
anchors.bottom: view.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
}
/* 《程式語言教學誌》的範例程式
http://kaiching.org/
檔名:main.qml
功能:示範 Swipe 型態
作者:張凱慶 */
回到練習題目