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
file.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 <QFile>
5#include <QTextStream>
6
7static void process_line(const QByteArray &)
8{
9}
10
11static void process_line(const QString &)
12{
13}
14
15static void noStream_snippet()
16{
18 QFile file("in.txt");
20 return;
21
22 while (!file.atEnd()) {
25 }
27}
28
30{
32 QFile file("in.txt");
34 return;
35
37 while (!in.atEnd()) {
38 QString line = in.readLine();
40 }
42}
43
45{
47 QFile file("out.txt");
49 return;
50
52 out << "The magic number is: " << 49 << "\n";
54}
55
57{
58 QFile file("out.dat");
60 return;
61
63 out << "The magic number is: " << 49 << "\n";
64}
65
67{
69 QFile file("/proc/modules");
71 return;
72
74 QString line = in.readLine();
75 while (!line.isNull()) {
77 line = in.readLine();
78 }
80}
81
82int main()
83{
84 lineByLine_snippet();
85 writeStream_snippet();
86}
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:46
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
\inmodule QtCore
Definition qfile.h:93
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:904
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition qstring.h:994
\inmodule QtCore
static void writeTextStream_snippet()
Definition file.cpp:44
static void noStream_snippet()
Definition file.cpp:15
static void writeDataStream_snippet()
Definition file.cpp:56
static void readRegularEmptyFile_snippet()
Definition file.cpp:66
static void readTextStream_snippet()
Definition file.cpp:29
int main()
Definition file.cpp:82
static void process_line(const QByteArray &)
Definition file.cpp:7
GLuint in
QFile file
[0]
QTextStream out(stdout)
[7]