QML-small example-file directory browser

Source: Internet
Author: User

QML-small example-file directory browser

QML Write animation is more convenient, reference QML provides examples of the following on Android available file directory browser (computer-side actually also available, just not complete)

These two are on the computer directly when the appearance of running on the Android phone, there will be some small differences.

The code for Filelistview.xml is probably as follows:

Import QtQuick2.3Import Qt.labs.folderlistmodel2.1Import QtQuick.Controls.Styles1.2Import Qtquick.controls1.2Rectangle {id:root; State:"Hidden"; Color:"#212126"; PropertystringFolderpathname:"file:///H:/TTPmusic/"; PropertyBOOLRootPath:false; Signal Message (stringmsg); PropertyintLineheight: -; Signal Selectedfolder (stringFolderPath);        linestyle{Id:topline; Text:"...";        Width:root.width;        Height:root.lineHeight; FontSize: +; 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 ("\ Foldermodel.folder:", Foldermodel.folder,"\ Foldermodel.parentfolder:", Foldermodel.parentfolder,"\ 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: *; 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,"\ Foldermodel.parentfolder:", Foldermodel.parentfolder,"\ Foldermodel.rootfolder:", Foldermodel.rootfolder,"\ Foldermodel.isfolder:", Foldermodel.isfolder (index)); Console.log ("\ n fileName:", Foldermodel.Get(Index,"FileName"),                            "\ FilePath:", Foldermodel.Get(Index,"FilePath"),                            "\ FileURL:", Foldermodel.Get(Index,"FileURL"),                            "\ filebasename:", Foldermodel.Get(Index,"Filebasename"),                            "\ Filesuffix:", Foldermodel.Get(Index,"Filesuffix"),                            "\ fileSize:", Foldermodel.Get(Index,"fileSize"),                            "\ filemodified:", Foldermodel.Get(Index,"filemodified"),                            "\ fileaccessed:", Foldermodel.Get(Index,"fileaccessed"),                            "\ 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 ("\ Foldermodel.folder:", Foldermodel.folder,"\ Foldermodel.parentfolder:", Foldermodel.parentfolder,"\ 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"; }    }}

Leave this memo.

QML-small example-file directory browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.