Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
src_corelib_io_qabstractfileengine.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
6{
7public:
8 QAbstractFileEngine *create(const QString &fileName) const override;
9};
10
12{
13 // ZipEngineHandler returns a ZipEngine for all .zip files
14 return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
15}
16
17int main(int argc, char **argv)
18{
19 QApplication app(argc, argv);
20
22
24 window.show();
25
26 return app.exec();
27}
29
30
33{
34 // ZipEngineHandler returns a ZipEngine for all .zip files
35 return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0;
36}
38
39
42CustomFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames)
43{
44 return new CustomFileEngineIterator(filters, filterNames);
45}
47
48
51{
52public:
55 {
56 // In a real iterator, these entries are fetched from the
57 // file system based on the value of path().
58 entries << "entry1" << "entry2" << "entry3";
59 }
60
61 bool hasNext() const override
62 {
63 return index < entries.size() - 1;
64 }
65
66 QString next() override
67 {
68 if (!hasNext())
69 return QString();
70 ++index;
71 return currentFilePath();
72 }
73
75 {
76 return entries.at(index);
77 }
78
79private:
80 QStringList entries;
81 int index;
82};
QString next() override
This pure virtual function advances the iterator to the next directory entry, and returns the file pa...
CustomIterator(const QStringList &nameFilters, QDir::Filters filters)
bool hasNext() const override
This pure virtual function returns true if there is at least one more entry in the current directory ...
\inmodule QtCore \reentrant
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
QDir::Filters filters() const
Returns the entry filters for this iterator.
QStringList nameFilters() const
Returns the name filters for this iterator.
virtual QString currentFilePath() const
Returns the path to the current directory entry.
\inmodule QtCore \reentrant
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QAbstractFileEngine * create(const QString &fileName) const override
[0]
int main()
[0]
GLuint index
[2]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QApplication app(argc, argv)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()
QJSEngine engine
[0]