QML - 小例子 - 文件目录浏览器

QML写动画比较方便,参考QML提供的例子写了如下在Android上可用的文件目录浏览器(电脑端其实也可用,只是还不完整)

以上这两张截图是在电脑上直接运行时的样子,在Android手机上运行的话,会有一些小差异。

FileListView.xml的代码大概如下:

import QtQuick 2.3
import Qt.labs.folderlistmodel 2.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 1.2Rectangle {id:root;state:"hidden";color: "#212126";property string folderPathName: "file:///H:/TTPmusic/";property bool rootPath:false;signal message(string msg);property int lineHeight: 90;signal selectedFolder(string folderPath);LineStyle{id:topLine;text: "...";width: root.width;height: root.lineHeight;fontSize:40;selectable:false;source: "res/image/arrow-1-backward.png";onClicked: {console.log("topLine  onClicked");if (folderModel.parentFolder != ""){root.folderPathName = folderModel.parentFolder;//text = root.folderPathName.slice(8);
            }else{//Fns.set_path_result(0);root.state = "hidden";}console.log("topLine root.folderPathName:", root.folderPathName);console.log("\n       folderModel.folder:", folderModel.folder,"\n folderModel.parentFolder:", folderModel.parentFolder,"\n   folderModel.rootFolder:", folderModel.rootFolder);}}ListView{id:listFileView;anchors{bottom: rectangleButton.top;bottomMargin: 4;right: root.right;rightMargin: 0;left: root.left;leftMargin: 0;top: topLine.bottom;topMargin: 0;}clip:true;delegate:LineStyle{text: fileName;height:root.lineHeight;width:root.width;fontSize:35;source: folderModel.get(index, "fileIsDir")?"res/image/folder.png":"";selectable:folderModel.get(index, "fileIsDir")?false:true;isdir: folderModel.get(index, "fileIsDir")?true:false;onClicked: {console.log("\nlistFileView  onClicked F:", folderModel.folder,"\n folderModel.parentFolder:", folderModel.parentFolder,"\n   folderModel.rootFolder:", folderModel.rootFolder,"\n     folderModel.isFolder:", folderModel.isFolder(index));console.log("\n      fileName:",  folderModel.get(index, "fileName"),"\n      filePath:",  folderModel.get(index, "filePath"),"\n       fileURL:",  folderModel.get(index, "fileURL"),"\n  fileBaseName:",  folderModel.get(index, "fileBaseName"),"\n    fileSuffix:",  folderModel.get(index, "fileSuffix"),"\n      fileSize:",  folderModel.get(index, "fileSize"),"\n  fileModified:",  folderModel.get(index, "fileModified"),"\n  fileAccessed:",  folderModel.get(index, "fileAccessed"),"\n     fileIsDir:",  folderModel.get(index, "fileIsDir"));if(folderModel.isFolder(index)){root.folderPathName = folderModel.get(index, "fileURL");}}onSelectfile: {//add_song_to_list!console.log("onSelectfile: ", folderModel.get(index, "fileURL"));}}model: FolderListModel{id:folderModel;objectName: "folderModel";showDirs: true;showFiles: true;showDirsFirst: true;nameFilters: ["*.mp3", "*.flac"];folder:root.folderPathName;onFolderChanged: {console.log("onFolderChanged root.folderPathName:", root.folderPathName);console.log("\n               folderModel.folder:", folderModel.folder,"\n         folderModel.parentFolder:", folderModel.parentFolder,"\n           folderModel.rootFolder:", folderModel.rootFolder);}}}Rectangle {id: rectangleButton;height: lineHeight;color: "#212126";anchors{left: root.left;leftMargin: 0;right: root.right;rightMargin: 0;bottom: root.bottom;bottomMargin: 0;}Rectangle{id:rectWhiteLine;anchors{left:parent.left;right: parent.right;top:parent.top;}height: 2;color:"white";}}
}

留此备忘。

转载于:https://www.cnblogs.com/listensong/p/4202039.html

QML - 小例子 - 文件目录浏览器相关推荐

  1. spring mvc文件上传小例子

    spring mvc文件上传小例子 1.jsp页面 <%@page contentType="text/html;charset=UTF-8"%> <%@page ...

  2. 基于vue-cli、elementUI的Vue超简单入门小例子

    基于vue-cli.elementUI的Vue超简单入门小例子 这个例子还是比较简单的,独立完成后,能大概知道vue是干嘛的,可以写个todoList的小例子. 开始写例子之前,先对环境的部署做点简单 ...

  3. C# 实现 rtc_通过Xlua实现unity热更新的一个小例子

    通过Xlua实现unity热更新的一个小例子 一.介绍 ​ 热更新是指在更新游戏资源或者逻辑的时候不需要开发者将游戏再打包.发布.玩家重新下载安装包,而是可以通过将需要更新的资源打包成AssetBun ...

  4. unity案例 mysql lua_通过Xlua实现unity热更新的一个小例子

    通过Xlua实现unity热更新的一个小例子 一.介绍 ​ 热更新是指在更新游戏资源或者逻辑的时候不需要开发者将游戏再打包.发布.玩家重新下载安装包,而是可以通过将需要更新的资源打包成AssetBun ...

  5. html5 websocket插件,html5实现的WebSocket一个小例子(附代码)

    本篇文章给大家带来的内容是关于html5实现的WebSocket一个小例子(附代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 客户端代码: var socket; if (&q ...

  6. Flask+Axios+jQuery构建前后端通信的小例子

    比较暴力但好理解的方法,下面详细说一下. 工具准备 Flask pip install flask Axios https://cdnjs.cloudflare.com/ajax/libs/axios ...

  7. Tensorflow神经网络框架 小例子 三层神经网络 卷积神经网络 循环神经网络 神经网络可视化

    Tensorflow神经网络框架 以前我们讲了神经网络基础,但是如果从头开始实现,那将是一个庞大且费时的工作,所以我们选择一条捷径---神经网络框架.我理解的神经网络框架就相当于一个工具包.就比如我们 ...

  8. Qt小例子学习52 - 卡片游戏

    Qt小例子学习52 - 卡片游戏 Card.qml import QtQuick 2.0 import QtQuick.Layouts 1.3Item {id: cardLayout.fillWidt ...

  9. JointJS简单小例子

    JointJS是一个HTML5的JavaScript库,用于创建完全互动式的图表,它极易上手且操作简单,并且支持所有的现代浏览器,对于时间紧迫的我们非常有利.我们可以使用JointJS已提供的图元素绘 ...

最新文章

  1. python有哪些常用的package_python package相关机制总结
  2. dede织梦调用顶级二级栏目及下三级栏目方法(数据库实现)
  3. 轻量级ORM框架——第二篇:Dapper中的一些复杂操作和inner join应该注意的坑
  4. python读取fiddler_python3 使用Fiddler捕获的Raw信息带cookie使用GET或POST获取
  5. 学习 SQL 语句 - Select(7): 分组统计之 Avg()、Sum()、Max()、Min()、Count()
  6. cla c 语言编译器,第九章 CLA_C2000_C_Compiler.pdf
  7. java 友好时间显示_仿微信的IM聊天时间显示格式(含iOS/Android/Web实现)[图文+源码]...
  8. org.apache.subversion.javahl.ClientException: Working copy is not up-to-date
  9. mysql表索引类型修改_MySQL常用的建表、添加字段、修改字段、添加索引SQL语句写法总结...
  10. day_work_01
  11. python中迭代器_【Python】解析Python中的迭代器
  12. Tomcat中设计模式-门面模式
  13. 循环神经网络 递归神经网络_递归神经网络-第5部分
  14. 使用cardview和recycleview时碰到的一些问题
  15. C语言移动营业厅程序设计,C语言程序设计 陈锐主编,清华大学出版社)例题代码 前7章.doc...
  16. m4125idn如何扫描_京瓷ECOSYS M4125idn驱动
  17. wordpress 搭建的博客: 增加网站备案信息
  18. 每周读书#11 - 等一朵花开
  19. 2022-7-27 顾宇佳 学习笔记
  20. 前端播放视频有声音没有画面

热门文章

  1. 力扣(简单+中等)50题整理总结
  2. vue计算多列和_解决vue 表格table列求和的问题
  3. python 声明变量类型_每日一课 | Python 检查变量的类型
  4. 五天学习Mysql数据库教程(一)1.1数据库的基本概念
  5. java没有释放内存_java – G1年轻的GC没有释放内存 – 空间耗尽
  6. 计算机导论sql试题,sql语句查询 练习题
  7. sqlserver查询当月的每一天_SQL生成一年每一天的时间列表的几种方法
  8. linux mint 最新版,Linux Mint安装最新版R
  9. python pip工具命令_python 工具链 包管理工具 pip
  10. 前端遮罩层实现_css遮罩层怎么做?