Get a list of subdirectory and file in special path as soon as possible



  • how i can get a list of files and subdirectories in special path (for example D://mainDirectory) by windows system file
    or any other way that it is avalable get list of subdirectories and files as soon as possible.i want create an xml file by this list.
    i write a class by Qt libraries it work well when subdirectorys and files are not many but when i give a path consist of 2600 files and 395 subfolder dont work well and make a heavy process (cpu & memory usage) and program not responding
    if you have a good idea help me plz;

    I have a code editor with line number area. How i can change cursor position an it's anchore to nth textblock ( for example 1200th textblock).i check block by block and use
    QTextCursor::moveposition (QTextCursor::Down , QTextCursor::MoveAnchor) 1200 times;
    but there is a problem when the line number of codes is over 1500 it work with too delay becouse it check 1500 textblock and perform 1500 times "QTextCursor::moveposition (QTextCursor::Down , QTextCursor::MoveAnchor)"
    now you suppose we have over 8000 lines of codes what happend?????
    please help me an give a good solution;



  • Please tell us more details. ;-)

    1. Are you using Qt's Api or OS's API?

    If OS's API works very fast while Qt's QDir works rather slow, it is very likely to be a bug of Qt.

    1. Are you using QTextEdit or QPlainTextEdit?

    If you are using the formal, you can try the latter.

    Debao



  • thanks R.Herder

    1. it's not matter for me Qt’s Api or OS’s API only i want speed in getting list of files and subdirectories,
      2-it's QPlainTextEdit.infact i want provide a goto line action


  • oh
    please reply



  • Use QDirIterator instead of QDir.
    It uses less memory.
    If you don't call fileInfo() then you can avoid expensive "stat" operations (assuming you only need the filenames)

    This is somewhat optimised in Qt 4.8, so if you're using 4.7 you may consider upgrading.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.