当前位置:网站首页>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
}
}
边栏推荐
- taobao.trade.get( 获取单笔交易的部分信息),淘宝店铺订单接口,淘宝oAuth2.0接口,淘宝R2接口代码对接分享
- threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
- Bit by bit of OpenCV calling USB camera
- Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
- mongodb的认识
- Fabric.js 上划线、中划线(删除线)、下划线
- Wechat applet uses towxml to display formula
- Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
- taobao.logistics.dummy.send( 无需物流发货处理 )接口,淘宝店铺发货API接口,淘宝订单发货接口,淘宝r2接口,淘宝oAu2.0接口
- Fabric. JS upper dash, middle dash (strikethrough), underline
猜你喜欢

Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'

< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621

Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute

Makefile 分隔文件名与后缀

Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

How kaggle uses utility script

Socket and socket address

buuctf-pwn write-ups (7)

Tmall product details interface (APP, H5 end)
随机推荐
Add vector formula in rich text editor (MathType for TinyMCE, visual addition)
STM32 standard firmware library function name memory (II)
Pycharm连接远程服务器
mathML转latex
PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
Basic knowledge of QT original code
Yolov3 & yolov5 output result description
The evolution process of the correct implementation principle of redis distributed lock and the summary of redison's actual combat
tmall.product.schema.get( 产品信息获取schema获取 ),淘宝店铺上传商品API接口,淘宝商品发布接口,淘宝商品上传API接口,店铺上传接口,oAuth2.0接口
Ad20 cannot select the solution of component packaging in PCB editor
STM32 library function for GPIO initialization
String matching problem
2. Const pointer
tmall. product. schema. Get (product information acquisition schema acquisition), Taobao store upload commodity API interface, Taobao commodity publishing interface, Taobao commodity upload API interf
YoloV6训练:训练自己数据集遇到的各种问题
Fabric. Keep the original level when JS element is selected
Quick analysis: easy to share the Internet
The most complete analysis of Flink frame window function
Fabric. JS free draw circle
Understanding of mongodb