当前位置:网站首页>QML pop-up frame, customizable
QML pop-up frame, customizable
2022-07-02 15:14:00 【Jedy junior five】
import QtQuick 2.0
import Material 0.2 as M
import QtQuick.Layouts 1.12
import QtQml 2.12
Item {
id: root
anchors.fill: parent
visible: false
property var tabModel: [" page 1", " page 2", " page 3"] // tab title
property var tabDetail: [cb0, cb, cb2] // Components ID
property var tabFilter: [0, 1]//, 2] // To show tab The index of the value
property int currentIndex: 0
property string mainColor: M.Theme.primaryColor
onVisibleChanged: {
if(!visible){
currentIndex = 0
}else{
mainDlg.state = "show"
}
}
Behavior on visible {
enabled: visible
NumberAnimation {
duration: 400
}
}
onCurrentIndexChanged: {
}
MouseArea{
anchors.fill: parent
}
Component{
id: cb0
Item{
anchors.fill: parent
}
}
Component{
id: cb1
Item{
anchors.fill: parent
}
}
Component{
id: cb2
Item{
anchors.fill: parent
}
}
Rectangle{
anchors.fill: parent
color: "#30000000"
MouseArea{
anchors.fill: parent
onClicked: {
mainDlg.scale = 1.2
}
}
}
Rectangle{
id: dlgBaseline
height: 1
width: parent.width
anchors.top: parent.top
anchors.topMargin: parent.height / 10
color: "transparent"
}
Rectangle{
id: mainDlg
width: parent.width / 5 * 4
height: parent.height / 5 * 4
anchors.top: parent.bottom
anchors.left: parent.left
anchors.leftMargin: width / 10
radius: M.Units.dp(10)
Behavior on scale {
SequentialAnimation{
NumberAnimation{
from: 1
to: 1.1
duration: 200
easing.type: Easing.InOutQuad
}
NumberAnimation{
from: 1.1
to: 0.95
duration: 200
easing.type: Easing.InOutQuad
}
NumberAnimation{
from: 0.95
to: 1
duration: 200
easing.type: Easing.InOutQuad
}
}
}
states: [
State{
name: "show"
AnchorChanges{
target: mainDlg
anchors.top: dlgBaseline.bottom
}
},
State{
name: "hide"
AnchorChanges{
target: mainDlg
anchors.top: root.bottom
}
}
]
transitions: Transition {
AnchorAnimation{
duration: 200
}
}
MouseArea{
anchors.fill: parent
}
M.View{
// The title bar
id: tabTitle
width: parent.width
height: M.Units.dp(60)
backgroundColor: mainColor
radius: M.Units.dp(10)
Rectangle{
height: parent.height / 2
width: parent.width
color: mainColor
anchors.bottom: parent.bottom
}
M.Label{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: " Test pop up "
color: "white"
font.pixelSize: M.Units.dp(30)
font.bold: true
}
M.View{
// close button
width: M.Units.dp(40)
height: width
radius: width / 2
elevation: 1
anchors.top: parent.top
anchors.right: parent.right
anchors.margins: M.Units.dp(10)
backgroundColor: "white"
M.Icon{
width: parent.width / 3
height: width
anchors.centerIn: parent
source: Qt.resolvedUrl("images/close.svg")
}
M.Ink{
anchors.fill: parent
circular: true
onClicked: {
playSound()
if(dmTabDetail.item.working){
return
}
root.visible = false
mainDlg.state = "hide"
}
}
}
}
M.View{
// The navigation bar
id: tabNavigate
width: parent.width / 5
anchors.left: parent.left
anchors.top: tabTitle.bottom
anchors.bottom: parent.bottom
radius: M.Units.dp(10)
backgroundColor: "white"
M.View{
// Scroll bar
width: M.Units.dp(10)
height: parent.height
anchors.right: parent.right
backgroundColor: "lightgray"
radius: width / 2
M.View{
id: flickkkk
width: parent.width / 3 * 2
height: flickList.height / flickList.contentHeight * parent.height
anchors.horizontalCenter: parent.horizontalCenter
radius: width / 2
backgroundColor: "gray"
property int scrolly: flickList.contentY / (flickList.contentHeight - flickList.height) * (parent.height - height)
y: scrolly
}
}
Flickable{
id: flickList
anchors.fill: parent
anchors.bottomMargin: M.Units.dp(5)
clip: true
contentHeight: dmTabView.height + M.Units.dp(5)
Column{
id: dmTabView
width: parent.width - M.Units.dp(10)
anchors.top: parent.top
anchors.topMargin: M.Units.dp(5)
spacing: M.Units.dp(5)
Repeater{
id: dmTabVieList
model: tabModel.filter(function(r, index){
if(tabFilter.indexOf(index) != -1) return true })
delegate: M.View {
width: root.currentIndex == index? parent.width - M.Units.dp(5): parent.width - M.Units.dp(10)
height: root.currentIndex == index? M.Units.dp(60): M.Units.dp(50)
anchors.horizontalCenter: parent.horizontalCenter
elevation: root.currentIndex == index? 1: 0
backgroundColor: Qt.darker(mainColor, root.currentIndex == index? 1.5: 1)
radius: M.Units.dp(5)
M.Label{
anchors.fill: parent
anchors.leftMargin: M.Units.dp(15)
text: modelData
color: root.currentIndex == index? "white": "#2f2f2f"
font.pixelSize: M.Units.dp(20)
verticalAlignment: Text.AlignVCenter
}
M.Label{
visible: root.currentIndex == index
anchors.right: parent.right
anchors.rightMargin: M.Units.dp(15)
anchors.verticalCenter: parent.verticalCenter
text: ">"
font.bold: true
font.pixelSize: M.Units.dp(30)
color: "white"
}
M.Ink{
anchors.fill: parent
onClicked: {
if(dmTabDetail.item.working){
return
}
root.currentIndex = index
}
}
}
}
}
}
}
M.View{
// Detail column
anchors.left: tabNavigate.right
anchors.right: parent.right
anchors.top: tabTitle.bottom
anchors.bottom: parent.bottom
anchors.leftMargin: M.Units.dp(5)
Loader{
id: dmTabDetail
anchors.fill: parent
anchors.margins: M.Units.dp(10)
sourceComponent: tabDetail[currentIndex]
}
}
}
function show(){
root.visible = true
}
function hide(){
root.visible = false
}
}
边栏推荐
- 19_Redis_宕机后手动配置主机
- 11_Redis_Hyperloglog_命令
- Arithmetic operations and related exercises in C language
- Topology architecture of the minimum deployment of tidb cluster
- 06_栈和队列转换
- geoserver离线地图服务搭建和图层发布
- 【无标题】LeetCode 2321. 拼接数组的最大分数
- C thread transfer parameters
- 【C语言】详解指针的初阶和进阶以及注意点(1)
- C RichTextBox controls the maximum number of lines displayed
猜你喜欢

Practice of compiling principle course -- implementing an interpreter or compiler of elementary function operation language

CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E

05_ queue
[email protected] : The platform “win32“ is incompatible with this module."/>info [email protected] : The platform “win32“ is incompatible with this module.

C语言习题---(数组)

geoserver离线地图服务搭建和图层发布

Table responsive layout tips

18_Redis_Redis主从复制&&集群搭建

c语言入门--数组

17_Redis_Redis发布订阅
随机推荐
哈夫曼树:(1)输入各字符及其权值(2)构造哈夫曼树(3)进行哈夫曼编码(4)查找HC[i],得到各字符的哈夫曼编码
Apprendre le Code de la méthode de conversion du calendrier lunaire grégorien en utilisant PHP
Record an error report, solve the experience, rely on repetition
Tidb data migration tool overview
【无标题】LeetCode 2321. 拼接数组的最大分数
CTO如何帮助业务?
解决el-radio-group 回显后不能编辑问题
LeetCode 2310. 个位数字为 K 的整数之和
[untitled] leetcode 2321 Maximum score of concatenated array
03_線性錶_鏈錶
LeetCode_滑动窗口_中等_395.至少有 K 个重复字符的最长子串
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
How does CTO help the business?
LeetCode 2320. Count the number of ways to place the house
【NOI模拟赛】伊莉斯elis(贪心,模拟)
蜻蜓低代码安全工具平台开发之路
C thread transfer parameters
表格响应式布局小技巧
N皇后问题的解决
Introduction to C language -- array