Results 1 to 5 of 5

Thread: Work with directory and files

  1. #1
    Join Date
    Mar 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Work with directory and files

    Hi
    I want to write a function that give a path from user and put addresses of whole files and directory ( everything that is in that address ) in the QStringList . How can I do this ?
    ps : I try this with QDir and QFileInfo but I can't success . please help me .

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Work with directory and files

    QDir.entryList()
    QDir.entryInfoList()

    depending on what you're trying to accomplish.

  3. #3
    Join Date
    Mar 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Work with directory and files

    My program must do exactly these works :


    1 - I want from user to input a path like "C:\Qt\4.7.2\bin"
    2 - My program give this address .
    3 - My program puts absolute address of every file in user's path( in example "C:\Qt\4.7.2\bin" ) in the QStringList seperatly . for example after user write "C:\Qt\4.7.2\bin" my program puts every of these below addresses in QStringList :
    (I think that I define QStringList stl )
    stl[0] = "C:\Qt\4.7.2\bin\assistant.exe"
    stl[1] = "C:\Qt\4.7.2\bin\createpackage"
    stl[2] = "C:\Qt\4.7.2\bin\createpackage.bat"
    stl[3] = "C:\Qt\4.7.2\bincreatepackage.pl"
    ....

    please help me.
    thanks.

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Work with directory and files

    Read the documentation for the functions I listed above. Either one will do what you want.

  5. #5
    Join Date
    Mar 2011
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Work with directory and files

    Thank you very much, the tip was very usefull.Now I have a another question :
    I have a QStringList considering previous posts ( now my QStringList include some address of different files ) . How can I purge that QStringList so only files with .txt format exist in my QStringList ?
    Please help me.
    thank you

Similar Threads

  1. List all XML files in a directory
    By ouekah in forum Newbie
    Replies: 4
    Last Post: 30th August 2015, 08:47
  2. Count files of a directory
    By radu_d in forum Qt Programming
    Replies: 6
    Last Post: 27th March 2012, 03:17
  3. Display files of a Directory
    By mansu in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2009, 15:08
  4. directory and files
    By rmagro in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2008, 13:40
  5. trace new files in a directory
    By Fastman in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 12:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.