• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::
            遍歷一個目錄下的所有文件,使用QDirIterator很方便,不需要自己去實現遞歸:
            void Widget::browse() {
                QString path = QFileDialog::getExistingDirectory(this, tr(""), "/Users/Biao/Desktop");
                QDirIterator iter(path, QDirIterator::Subdirectories);
            
            
                while (iter.hasNext()) {
                    iter.next();
                    QFileInfo info = iter.fileInfo();
            
            
                    if (info.isFile()) {
                        qDebug() << info.absoluteFilePath();
                    }
                }
                //treeWalk(path);
            }
            
            

            QDirIterator Class Reference

            The QDirIterator class provides an iterator for directory entrylists. More...

             #include <QDirIterator>
            This class was introduced in Qt 4.3.

            List of all members, including inherited members
            Public Types

            enum IteratorFlag { NoIteratorFlags, Subdirectories, FollowSymlinks }
            flags IteratorFlags
            Public Functions

            QDirIterator ( const QDir & dir, IteratorFlags flags = NoIteratorFlags )
            QDirIterator ( const QString & path, IteratorFlags flags = NoIteratorFlags )
            QDirIterator ( const QString & path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags )
            QDirIterator ( const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, IteratorFlags flags = NoIteratorFlags )
            virtual ~QDirIterator ()
            QFileInfo fileInfo () const
            QString fileName () const
            QString filePath () const
            bool hasNext () const
            QString next ()
            QString path () const
            Detailed Description

            The QDirIterator class provides an iterator for directory entrylists.

            You can use QDirIterator to navigate entries of a directory one at a time. It is similar to QDir::entryList() and QDir::entryInfoList(), but because it lists entries one at a time instead of all at once, it scales better and is more suitable for large directories. It also supports listing directory contents recursively, and following symbolic links. Unlike QDir::entryList(), QDirIterator does not support sorting.

            The QDirIterator constructor takes a QDir or a directory as argument. After construction, the iterator is located before the first directory entry. Here's how to iterate over all the entries sequentially:

             QDirIterator it("/etc", QDirIterator::Subdirectories);
             while (it.hasNext()) {
                 qDebug() << it.next();

                 // /etc/.
                 // /etc/..
                 // /etc/X11
                 // /etc/X11/fs
                 // ...
             }
            The next() function returns the path to the next directory entry and advances the iterator. You can also call filePath() to get the current file path without advancing the iterator. The fileName() function returns only the name of the file, similar to how QDir::entryList() works. You can also call fileInfo() to get a QFileInfo for the current entry.

            Unlike Qt's container iterators, QDirIterator is uni-directional (i.e., you cannot iterate directories in reverse order) and does not allow random access.

            QDirIterator works with all supported file engines, and is implemented using QAbstractFileEngineIterator.

            See also QDir, QDir::entryList(), and QAbstractFileEngineIterator.

            Member Type Documentation

            enum QDirIterator::IteratorFlag
            flags QDirIterator::IteratorFlags

            This enum describes flags that you can combine to configure the behavior of QDirIterator.

            Constant Value Description
            QDirIterator::NoIteratorFlags 0x0 The default value, representing no flags. The iterator will return entries for the assigned path.
            QDirIterator::Subdirectories 0x2 List entries inside all subdirectories as well.
            QDirIterator::FollowSymlinks 0x1 When combined with Subdirectories, this flag enables iterating through all subdirectories of the assigned path, following all symbolic links. Symbolic link loops (e.g., "link" => "." or "link" => "..") are automatically detected and ignored.
            The IteratorFlags type is a typedef for QFlags<IteratorFlag>. It stores an OR combination of IteratorFlag values.

            Member Function Documentation

            QDirIterator::QDirIterator ( const QDir & dir, IteratorFlags flags = NoIteratorFlags )

            Constructs a QDirIterator that can iterate over dir's entrylist, using dir's name filters and regular filters. You can pass options via flags to decide how the directory should be iterated.

            By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

            The sorting in dir is ignored.

            Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

            See also hasNext(), next(), and IteratorFlags.

            QDirIterator::QDirIterator ( const QString & path, IteratorFlags flags = NoIteratorFlags )

            Constructs a QDirIterator that can iterate over path. You can pass options via flags to decide how the directory should be iterated.

            By default, flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

            Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

            See also hasNext(), next(), and IteratorFlags.

            QDirIterator::QDirIterator ( const QString & path, QDir::Filters filters, IteratorFlags flags = NoIteratorFlags )

            Constructs a QDirIterator that can iterate over path, with no name filtering and filters for entry filtering. You can pass options via flags to decide how the directory should be iterated.

            By default, filters is QDir::NoFilter, and flags is NoIteratorFlags, which provides the same behavior as in QDir::entryList().

            Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

            See also hasNext(), next(), and IteratorFlags.

            QDirIterator::QDirIterator ( const QString & path, const QStringList & nameFilters, QDir::Filters filters = QDir::NoFilter, IteratorFlags flags = NoIteratorFlags )

            Constructs a QDirIterator that can iterate over path, using nameFilters and filters. You can pass options via flags to decide how the directory should be iterated.

            By default, flags is NoIteratorFlags, which provides the same behavior as QDir::entryList().

            Note: To list symlinks that point to non existing files, QDir::System must be passed to the flags.

            See also hasNext(), next(), and IteratorFlags.

            QDirIterator::~QDirIterator () [virtual]

            Destroys the QDirIterator.

            QFileInfo QDirIterator::fileInfo () const

            Returns a QFileInfo for the current directory entry.

            See also filePath() and fileName().

            QString QDirIterator::fileName () const

            Returns the file name for the current directory entry, without the path prepended.

            This function is convenient when iterating a single directory. When using the QDirIterator::Subdirectories flag, you can use filePath() to get the full path.

            See also filePath() and fileInfo().

            QString QDirIterator::filePath () const

            Returns the full file path for the current directory entry.

            See also fileInfo() and fileName().

            bool QDirIterator::hasNext () const

            Returns true if there is at least one more entry in the directory; otherwise, false is returned.

            See also next(), fileName(), filePath(), and fileInfo().

            QString QDirIterator::next ()

            Advances the iterator to the next entry, and returns the file path of this new entry. If hasNext() returns false, this function does nothing, and returns a null QString.

            You can call fileName() or filePath() to get the current entry file name or path, or fileInfo() to get a QFileInfo for the current entry.

            See also hasNext(), fileName(), filePath(), and fileInfo().

            QString QDirIterator::path () const

            Returns the base directory of the iterator.
            posted on 2011-12-02 00:19 逛奔的蝸牛 閱讀(6930) 評論(0)  編輯 收藏 引用 所屬分類: Qt
            久久国产乱子伦精品免费午夜| 亚洲人AV永久一区二区三区久久| A级毛片无码久久精品免费| 久久SE精品一区二区| 久久99热国产这有精品| 欧美精品丝袜久久久中文字幕| 亚洲欧美成人久久综合中文网 | 一本伊大人香蕉久久网手机| 国产精品丝袜久久久久久不卡| 久久人妻少妇嫩草AV蜜桃| 国产精品久久影院| 久久精品一本到99热免费| 亚洲国产天堂久久综合网站| 狠狠色噜噜色狠狠狠综合久久| 伊人色综合久久| 久久精品国产亚洲AV无码麻豆| 亚洲国产日韩欧美久久| 91久久精品无码一区二区毛片| A级毛片无码久久精品免费| 久久久久婷婷| Xx性欧美肥妇精品久久久久久 | 久久精品中文字幕一区| 国产亚洲色婷婷久久99精品91 | av无码久久久久不卡免费网站| 亚洲精品成人久久久| 国产精品无码久久四虎| 久久无码av三级| 久久99精品国产99久久| 久久综合亚洲欧美成人| 久久精品国产亚洲av麻豆蜜芽| 久久精品成人欧美大片| 精品水蜜桃久久久久久久| 91精品国产91热久久久久福利| 国内精品久久久久久久97牛牛| 欧美日韩精品久久久免费观看| 中文字幕亚洲综合久久菠萝蜜| 日韩精品无码久久一区二区三| 久久久中文字幕日本| 亚洲另类欧美综合久久图片区| 国产精品中文久久久久久久| 久久久久人妻一区二区三区|