赞
踩
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 Window { id: root visible: true width: 640 height: 480 title: qsTr("test") color:"lightgray" TabBar { //点击相应的按钮实现切换 id: bar width: parent.width TabButton { text: qsTr("First") } TabButton { text: qsTr("Second") } TabButton { text: qsTr("Third") } } StackLayout { //栈布局管理器 anchors.centerIn: parent width: parent.width currentIndex: bar.currentIndex //当前视图的索引 Item { Text { anchors.centerIn: parent text: qsTr("First") } } Item { Text { anchors.centerIn: parent text: qsTr("Second") } } Item { Text { anchors.centerIn: parent text: qsTr("Third") } } } }
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") SwipeView { id: view currentIndex: 0 anchors.fill: parent orientation: Qt.Horizontal interactive: true Rectangle { id: firstPage color: "purple" Text { text: qsTr("First") anchors.centerIn: parent font.pixelSize: 25 } } Rectangle { id: secondPage color: "blue" Text { text: qsTr("Second") anchors.centerIn: parent font.pixelSize: 25 } } Rectangle { id: thirdPage color: "green" Text { text: qsTr("Third") anchors.centerIn: parent font.pixelSize: 25 } } } header: TabBar { //窗口标题 是 ApplicationWindow 的属性 id: headertabBar; currentIndex:view.currentIndex TabButton { text: qsTr("header one"); } TabButton { text: qsTr("header two") } TabButton { text: qsTr("header three") } } }
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("ToolBar") color: "lightgray" header: ToolBar { //窗口标题栏设置ToolBar RowLayout { anchors.fill: parent ToolButton { //此按钮是关联上下文 text: qsTr("‹") //回退按钮 onClicked: stack.pop() } Label { text: "Two" //标题名 horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter Layout.fillWidth: true } ToolButton { id: fileButton; text: qsTr("⋮") //菜单隐藏按钮 onClicked: menu.open() } } } Menu { id: menu x: fileButton.x; y: fileButton.y; Action { text: "Cut" } Action { text: "Copy" } Action { text: "Paste" } } StackView { id: stack anchors.fill: parent } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。