QT WIN11 FluentUI APP开发

news2024/9/25 13:18:20
代码
import QtQuick
import QtQuick.Controls
import FluentUI

Item {
    property bool autoPlay: true
    property int loopTime: 2000
    property var model
    property Component delegate
    property bool showIndicator: true
    property int indicatorGravity : Qt.AlignBottom | Qt.AlignHCenter
    property int indicatorMarginLeft: 0
    property int indicatorMarginRight: 0
    property int indicatorMarginTop: 0
    property int indicatorMarginBottom: 20
    property int indicatorSpacing: 10
    property alias indicatorAnchors: layout_indicator.anchors
    property Component indicatorDelegate : com_indicator
    id:control
    width: 400
    height: 300
    ListModel{
        id:content_model
    }
    QtObject{
        id:d
        property bool flagXChanged: true
        property bool isAnimEnable: control.autoPlay && list_view.count>3
        function setData(data){
            if(!data){
                return
            }
            content_model.clear()
            content_model.append(data[data.length-1])
            content_model.append(data)
            content_model.append(data[0])
            list_view.highlightMoveDuration = 0
            list_view.currentIndex = 1
            list_view.highlightMoveDuration = 250
            if(d.isAnimEnable){
                timer_run.restart()
            }
        }
    }
    ListView{
        id:list_view
        anchors.fill: parent
        snapMode: ListView.SnapOneItem
        clip: true
        boundsBehavior: ListView.StopAtBounds
        model:content_model
        maximumFlickVelocity: 4 * (list_view.orientation === Qt.Horizontal ? width : height)
        preferredHighlightBegin: 0
        preferredHighlightEnd: 0
        highlightMoveDuration: 0
        Component.onCompleted: {
            d.setData(control.model)
        }
        interactive: list_view.count>3
        Connections{
            target: control
            function onModelChanged(){
                d.setData(control.model)
            }
        }
        orientation : ListView.Horizontal
        delegate: Item{
            id:item_control
            width: ListView.view.width
            height: ListView.view.height
            property int displayIndex: {
                if(index === 0)
                    return content_model.count-3
                if(index === content_model.count-1)
                    return 0
                return index-1
            }
            FluLoader{
                property int displayIndex : item_control.displayIndex
                property var model: list_view.model.get(index)
                anchors.fill: parent
                sourceComponent: {
                    if(model){
                        return control.delegate
                    }
                    return undefined
                }
            }
        }
        onMovementEnded:{
            currentIndex = list_view.contentX/list_view.width
            if(currentIndex === 0){
                currentIndex = list_view.count-2
            }else if(currentIndex === list_view.count-1){
                currentIndex = 1
            }
            d.flagXChanged = false
            timer_run.restart()
        }
        onMovementStarted: {
            d.flagXChanged = true
            timer_run.stop()
        }
        onContentXChanged: {
            if(d.flagXChanged){
                var maxX = Math.min(list_view.width*(currentIndex+1),list_view.count*list_view.width)
                var minY = Math.max(0,(list_view.width*(currentIndex-1)))
                if(contentX>=maxX){
                    contentX = maxX
                }
                if(contentX<=minY){
                    contentX = minY
                }
            }
        }
    }
    Component{
        id:com_indicator
        Rectangle{
            width:  8
            height: 8
            radius: 4
            FluShadow{
                radius: 4
            }
            scale: checked ? 1.2 : 1
            color: checked ?  FluTheme.primaryColor : Qt.rgba(1,1,1,0.7)
            border.width: mouse_item.containsMouse ? 1 : 0
            border.color: FluTheme.primaryColor
            MouseArea{
                id:mouse_item
                hoverEnabled: true
                anchors.fill: parent
                onClicked: {
                    changedIndex(realIndex)
                }
            }
        }
    }
    Row{
        id:layout_indicator
        spacing: control.indicatorSpacing
        anchors{
            horizontalCenter:(indicatorGravity & Qt.AlignHCenter) ? parent.horizontalCenter : undefined
            verticalCenter: (indicatorGravity & Qt.AlignVCenter) ? parent.verticalCenter : undefined
            bottom: (indicatorGravity & Qt.AlignBottom) ? parent.bottom : undefined
            top: (indicatorGravity & Qt.AlignTop) ? parent.top : undefined
            left: (indicatorGravity & Qt.AlignLeft) ? parent.left : undefined
            right: (indicatorGravity & Qt.AlignRight) ? parent.right : undefined
            bottomMargin: control.indicatorMarginBottom
            leftMargin: control.indicatorMarginBottom
            rightMargin: control.indicatorMarginBottom
            topMargin: control.indicatorMarginBottom
        }
        visible: showIndicator
        Repeater{
            id:repeater_indicator
            model: list_view.count
            FluLoader{
                property int displayIndex: {
                    if(index === 0)
                        return list_view.count-3
                    if(index === list_view.count-1)
                        return 0
                    return index-1
                }
                property int realIndex: index
                property bool checked: list_view.currentIndex === index
                sourceComponent: {
                    if(index===0 || index===list_view.count-1)
                        return undefined
                    return control.indicatorDelegate
                }
            }
        }
    }
    Timer{
        id:timer_anim
        interval: 250
        onTriggered: {
            list_view.highlightMoveDuration = 0
            if(list_view.currentIndex === list_view.count-1){
                list_view.currentIndex = 1
            }
        }
    }
    Timer{
        id:timer_run
        interval: control.loopTime
        repeat: d.isAnimEnable
        onTriggered: {
            list_view.highlightMoveDuration = 250
            list_view.currentIndex = list_view.currentIndex+1
            timer_anim.start()
        }
    }
    function changedIndex(index){
        d.flagXChanged = true
        timer_run.stop()
        list_view.currentIndex = index
        d.flagXChanged = false
        if(d.isAnimEnable){
            timer_run.restart()
        }
    }
}
效果 

 

参考

https://github.com/zhuzichu520/FluentUI

GitHub - zhuzichu520/FluentPlayer

GitHub - zhuzichu520/QtHub

https://blog.51cto.com/u_6343747/5465068

Felgo简介--Qt开发者的福音-CSDN博客


创作不易,小小的支持一下吧!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2073740.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【MySQL】一文带你理清<行级锁>(行锁,间隙锁,临键锁)

前言 大家好吖&#xff0c;欢迎来到 YY 滴MySQL系列 &#xff0c;热烈欢迎&#xff01; 本章主要内容面向接触过C Linux的老铁 主要内容含&#xff1a; 欢迎订阅 YY滴C专栏&#xff01;更多干货持续更新&#xff01;以下是传送门&#xff01; YY的《C》专栏YY的《C11》专栏YY的…

STM32(六):定时器——输出比较实验

PWM驱动呼吸灯 源码&#xff1a; #include "stm32f10x.h" // Device headervoid PWM_Init(void) {RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);//开启时钟TIM_InternalClockConfig(TIM2);//选择时基单元的时钟TIM_TimeBaseInitTypeDef TI…

怎么管控终端电脑上的移动端口

管控终端电脑上的移动端口&#xff0c;尤其是USB等移动端口&#xff0c;是确保企业数据安全和提升网络管理效率的重要手段。 一、使用注册表编辑器禁用USB端口&#xff08;适用于Windows系统&#xff09; 打开注册表编辑器&#xff1a; 同时按下“WinR”组合键&#xff0c;打…

【C++从小白到大牛】C++智能指针的使用、原理和分类

目录 1、我们为什么需要智能指针&#xff1f; 2、内存泄露 2.1 什么是内存泄漏&#xff0c;内存泄漏的危害 2.2如何避免内存泄漏 总结一下: 3.智能指针的使用及原理 3.1 RAII 3.2关于深拷贝和浅拷贝更深层次的理解&#xff1a; 3.3 std::auto_ptr 3.4 std::unique_pt…

《黑神话:悟空》登顶全球:游戏行业投资新风向与投资洞察

目录 引言 一、原创IP的崛起&#xff1a;文化共鸣与市场潜力 1《黑神话:悟空》的原创IP魅力 2 原创IP在游戏行业中的重要性 3 原创IP成为新的投资热点 4 文化共鸣的关键作用 二、高质量内容为王&#xff1a;技术与创新的双重驱动 1 《黑神话:悟空》的高质量内容展示 2…

Java接口interface(内含练习)

为什么有接口&#xff1f; 接口就是一种规则&#xff0c;更侧向是一种行为 接口的定义和使用 接口用关键字interface来定义 public interface 接口名{} 接口不能实例化 接口和接口之间是实现关系&#xff0c;通过implements关键字表示 public class 类名 implements 接口…

浅谈线性表——链表

文章目录 一、ArrayList的缺陷二、什么是链表&#xff1f;三、自我实现一个单向不带头非循环结构的链表3.1、实现代码3.2、代码解析 四、自我实现一个双向不带头非循环结构的链表4.1、实现代码 一、ArrayList的缺陷 前面学习了顺序表&#xff0c;顺序表在知道下标时可以快速的…

python应用之random模块(居然还有那么多的随机算法函数)

random 是 Python 的一个常用的内置模块&#xff0c;模块提供了生成随机数的功能&#xff0c;包含了多种生成随机数的函数&#xff0c;比如生成随机整数、随机浮点数、从序列中随机选择元素等。 使用 random模块 要使用 random模块&#xff0c;直接导入它即可。 import rand…

spring揭秘09-aop03-aop织入器织入横切逻辑与自动织入

文章目录 【README】【1】spring aop的织入【1.1】使用ProxyFactory 作为织入器【1.2】基于接口的代理&#xff08;JDK动态代理&#xff0c;目标类实现接口&#xff09;【补充】 【1.2】基于类的代理&#xff08;CGLIB动态代理&#xff0c;目标类没有实现接口&#xff09;【1.2…

Nginx: 配置项之autoIndex模块与Nginx变量

autoIndex模块 autoindex模块它所实现的一个基本功能&#xff0c;是当用户请求以 / 结尾式的URL&#xff0c;它会列出对应的目录结构比如说, 在实际的生态环境中&#xff0c;内部系统可能经常需要为用户提供一些下载功能。可能需要列出来某一个磁盘上的一个文件&#xff0c; 比…

【D-DCVRP】求解DCVRP改进贪婪算法(三)

一、Held-Harp模型 海尔德和卡尔普在1970年提出景点模型,用于求解TSP问题的最优解下界 该模型同样可以用于DCVRP问题,既有定理1成立。 定理1:根据Held-Karp模型使用向量 π = ( 0 , π 1 , π 2 , ⋯   , π n ) \pi=(0,\pi_1,\pi_2,\cdots,\pi_n) π=(0,π1​,π2​,⋯…

Datawhale第五期夏令营-CV竞赛

CV竞赛 0.赛事报名租用4090 1.开始运行下载文件提交结果 2.内容解释赛题背景赛题目标社会价值评分规则baseline精读代码什么是YOLO 主要代码内容精读使用Ultraalytics运行代码 0.赛事报名 赛事官网:https://www.marsbigdata.com/competition/details?id3839107548872 租用40…

【Redis】RDB和AOF持久化

RDB和AOF持久化 一、什么是持久化&#xff1f;二、RDB三、AOF 一、什么是持久化&#xff1f; 数据一般写在内存上&#xff0c;但是当重新启动计算机内存数据是会丢失的&#xff0c;而硬盘中的数据是不会丢失的&#xff0c;所以&#xff0c;当我们把数据从内存放到硬盘中的话就…

解决Windows下载完anaconda之后,在pycharm中使用anaconda

怎么下载anaconda我就不详细讲了&#xff0c;就是官方下载基本嫩都是下一步下一步你就可以 一、首先配置环境变量如图 二、查看anaconda情况 三、打开pycharm,如下图操作 ## 注意这里的.bat文件需要在你下载到的anaconda中去找 完毕

6款ai智能文章改写软件,轻松实现文章自动改写

在内容创作领域&#xff0c;改写文章是一项费时费力的工作。为了让创作者从繁琐的改写任务中解脱出来&#xff0c;本文将为你详细介绍六款ai智能文章改写软件&#xff0c;助你轻松实现文章自动改写&#xff0c;提升创作效率。 一、创作者的痛点&#xff1a;文章改写的挑战 作为…

【C++ Primer Plus习题】5.5

问题: 解答: #include <iostream> using namespace std;#define MONTHSCOUNT 12int main() {string months[MONTHSCOUNT] { "January","February","March","April","May","June","July","…

高斯混合模型原理及Python实践

高斯混合模型&#xff08;Gaussian Mixture Model&#xff0c;简称GMM&#xff09;是一种统计学中的概率模型&#xff0c;用于表示由多个高斯分布&#xff08;正态分布&#xff09;混合组成的数据集合。其核心原理基于假设数据集中的每个数据点都是由多个潜在的高斯分布之一生成…

SAP商业地产管理(RE-FX)

SAP 提供了多个模块来支持租赁业务流程和会计处理&#xff0c;这些模块包括但不限于&#xff1a; SAP Leasing&#xff1a;这是一个为租赁公司提供的行业解决方案&#xff0c;支持从租赁起源到中期变更和租赁结束选项的所有阶段的业务流程。SAP Leasing 集成了 SAP CRM 和 SAP …

Java 中的 BIO, NIO, AIO 原理以及示例代码

本文参考&#xff1a; https://blog.csdn.net/yhl_jxy/article/details/79335692 https://www.cnblogs.com/cuzzz/p/17290070.html https://www.cnblogs.com/cuzzz/p/17473398.html https://pdai.tech/md/java/io/java-io-nio-select-epoll.html 最近准备看 Kafka 源码&#xf…

2-76 基于matlab的加权平均融合算法

基于matlab的加权平均融合算法&#xff0c;进行灰度或彩色多模态医学图像融合&#xff0c;程序具体很好的通用性&#xff0c;提供图像融合客观评价指标&#xff0c;还给出3组珍贵的已配准的图像。程序已调通&#xff0c;可直接运行。 2-76 多模态医学图像融合 - 小红书 (xiaoho…