当前位置:网站首页>qml 弹窗框架,可定制
qml 弹窗框架,可定制
2022-07-02 11:24:00 【jeady小五】
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: ["页面1", "页面2", "页面3"] // tab 标题
property var tabDetail: [cb0, cb, cb2] // 组件ID
property var tabFilter: [0, 1]//, 2] // 要显示的tab的索引值
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{
// 标题栏
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: "测试弹窗"
color: "white"
font.pixelSize: M.Units.dp(30)
font.bold: true
}
M.View{
// 关闭按钮
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{
// 导航栏
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{
// 滚动栏
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{
// 详细栏
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
}
}
边栏推荐
- buuctf-pwn write-ups (7)
- Simple verification code generator for 51 single chip microcomputer experiment
- 1. Editing weapon VIM
- Daily learning 2
- Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
- The use of TestNG, the testing framework (II): the use of TestNG XML
- Ad20 cannot select the solution of component packaging in PCB editor
- Basic knowledge of QT original code
- [QNX hypervisor 2.2 user manual]6.3 communication between guest and external
- threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
猜你喜欢

STM32 library function for GPIO initialization

Fabric. JS free draw circle

Daily learning 2

《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持

<口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持

富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)

Development and design of animation surrounding mall sales website based on php+mysql

Fabric. JS upper dash, middle dash (strikethrough), underline

途家木鸟美团夏日折扣对垒,门槛低就一定香吗?

Fabric.js 自由绘制圆形
随机推荐
【apipost】使用教程
< schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv
Fabric. JS upper dash, middle dash (strikethrough), underline
obsidian安装第三方插件——无法加载插件
[QNX Hypervisor 2.2用户手册]6.3 Guest与外部之间通信
Fatal: unsafe repository is owned by someone else
Simple verification code generator for 51 single chip microcomputer experiment
Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
PyQt5_ Qscrollarea content is saved as a picture
什么是 eRDMA?丨科普漫画图解
uniapp自动化测试学习
Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
[development environment] StarUML tool (download software | StarUML installation | StarUML creation project)
freemarker的使用
Add vector formula in rich text editor (MathType for TinyMCE, visual addition)
Understanding of mongodb
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
Fabric.js 自由绘制椭圆
Tmall product details interface (APP, H5 end)