Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QDir>
5#include <iostream>
6
7int main(int argc, char *argv[])
8{
9 QDir dir;
11 dir.setSorting(QDir::Size | QDir::Reversed);
12
15 filters << "*.cpp" << "*.cxx" << "*.cc";
16 dir.setNameFilters(filters);
18
19 QFileInfoList list = dir.entryInfoList();
20 std::cout << " Bytes Filename" << std::endl;
21 for (int i = 0; i < list.size(); ++i) {
22 QFileInfo fileInfo = list.at(i);
23 std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10)
24 .arg(fileInfo.fileName()));
25 std::cout << std::endl;
26 }
27 return 0;
28}
\inmodule QtCore
Definition qdir.h:20
@ Size
Definition qdir.h:52
@ Reversed
Definition qdir.h:57
@ Files
Definition qdir.h:23
@ Hidden
Definition qdir.h:35
@ NoSymLinks
Definition qdir.h:25
QString fileName() const
qint64 size() const
Returns the file size in bytes.
qsizetype size() const noexcept
Definition qlist.h:397
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
int main()
[0]
SSL_CTX int void * arg
#define qPrintable(string)
Definition qstring.h:1531
QList< int > list
[14]
QString dir
[11]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]