I want to count number of file in a directory, I used count method in QDir class but it always return number of file plus two! why does it do this work ? thanks
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
QDir.count()
returns the total count of files and directories in the directory. This includes the.
(this) and..
(parent) directory entries. So the count is always two more than the "real" files and subdirectories.You'll need exclude
.
and..
-QDir::Files
filter can help you there.Relevant docs:
You Can use :
using file name
You should use
flags QDir::Filters
withQDir::NoDotAndDotDot
I am posting a complete answer.