Results 1 to 2 of 2

Thread: find all files with a certain extention + folder control

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default find all files with a certain extention + folder control

    Hi,

    I have 2 questions:

    1) I need to find all files in the current folder that have a *.txt extention. Then I want to sequentially open these files and use them.
    What is the easiest files to get all filenames with a certain extention?
    I would like to obtain these files sequentially - find one, do something, find another, do something etc.

    2) How do you detect the presence or absence of folders and how do you create new folders with Qt?

    Thanks a lot!
    Last edited by tommy; 19th March 2009 at 14:39.

  2. #2
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: find all files with a certain extention + folder control

    Here's an example of how to list files in a directory from Qt Documentation (link):
    Qt Code:
    1. #include <QDir>
    2. #include <iostream>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication app(argc, argv);
    7. QDir dir;
    8. dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    9. dir.setSorting(QDir::Size | QDir::Reversed);
    10.  
    11. QFileInfoList list = dir.entryInfoList();
    12. std::cout << " Bytes Filename" << std::endl;
    13. for (int i = 0; i < list.size(); ++i) {
    14. QFileInfo fileInfo = list.at(i);
    15. std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
    16. .arg(fileInfo.fileName()));
    17. std::cout << std::endl;
    18. }
    19. return 0;
    20. }
    To copy to clipboard, switch view to plain text mode 

    Directories can be created with mkdir and to check if they exist use exists.

  3. The following user says thank you to arturo182 for this useful post:

    tommy (19th March 2009)

Similar Threads

  1. Mingw doesn't find qt include files
    By NineTailFox in forum Newbie
    Replies: 2
    Last Post: 12th November 2008, 08:18
  2. visual studio project files - adding extra files
    By luf in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 21:05
  3. Find font files
    By kovid in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2008, 22:59
  4. problems installing Qt opensource with msvc2008 support
    By odin1985 in forum Installation and Deployment
    Replies: 6
    Last Post: 24th May 2008, 09:06
  5. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.