×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    2

    How to use QFileDialog or another way for file browsing in QML UI ?

    Hello,
    I have got a QML UI running in N900 and in the opening page I want the user browse a working folder. The application will get this directory and use it with Qt/C++.
    My question is quite simple. Is there any way to implement a file browsing application which user can use it to jump between folders in QML ?

    One option is to integrate my existing QML-UI with a QWidget-based UI, however, I wanna learn if there is any other way to create a file browsing in QML with QFileDialog or something else.


    Thanks
    Last edited by magpielover; 2011-05-07 at 11:46.

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: How to use QFileDialog or another way for file browsing in QML UI ?

    The QMLViewer has, IIRC, a file browser feature, implemented I'm sure with the QML ListView Element and the QML FolderListModel Element. Have a look at that piece of code as an example ...
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    2

    Re: How to use QFileDialog or another way for file browsing in QML UI ?

    Hello,
    I haven't found any piece of code which allows user select a directory nor will return an existing directory selected by the user. I' m trying to send the directory through a signal to Qt but the problem is selecting the directory in QML.
    I am seriously stuck here. QML restricts me from creating a file browsing tool. I simply want my application branch to user folders but no luck yet.

    Hope somebody has found a solution.

  4. #4
    Nokia Developer Moderator
    Join Date
    Jul 2006
    Location
    Tampere, Finland
    Posts
    13

    Re: How to use QFileDialog or another way for file browsing in QML UI ?

    Have you tried the example from http://doc.trolltech.com/4.7-snapsho...listmodel.html ?

    I expanded the code snippet a bit and here's a very simple and ugly but functional file browser:

    Code:
    import QtQuick 1.0
    import Qt.labs.folderlistmodel 1.0
    
    ListView {
        width: 360
        height: 640
        FolderListModel {
            id: foldermodel
            folder: "file:///c:/"
            nameFilters: ["*.*"]
            showDotAndDotDot: true
        }
    
        Component {
            id: filedelegate
            Rectangle {
                width: parent.width
                height: 30
                Text {
                    text: fileName+" "+filePath
                    anchors.fill: parent
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            if (foldermodel.isFolder(index)) {
                                foldermodel.folder = filePath
                            }
                        }
                    }
                }
            }
        }
    
        model: foldermodel
        delegate: filedelegate
    }
    - Late

Similar Threads

  1. How to call/load another QML file from QML ?
    By cadlg in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-07-28, 09:15
  2. How to use QML inside libraries
    By mnosov in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2011-01-14, 10:00
  3. how to use the touch ui in j2me
    By junaid888 in forum Mobile Java General
    Replies: 8
    Last Post: 2010-12-30, 11:31
  4. How to use UI components in fep?
    By DoiT in forum Symbian
    Replies: 2
    Last Post: 2008-09-03, 07:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×