Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_io_qfile.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
<
QDir
>
6
7
void
example
()
8
{
9
//! [0]
10
QFile file;
11
QDir::setCurrent(
"/tmp"
);
12
file.setFileName(
"readme.txt"
);
13
QDir::setCurrent(
"/home"
);
14
file.open(QIODevice::ReadOnly);
// opens "/home/readme.txt" under Unix
15
//! [0]
16
}
17
18
19
//! [3]
20
#
include
<
stdio
.
h
>
21
22
void
printError
(
const
char
* msg)
23
{
24
QFile file;
25
file.open(stderr, QIODevice::WriteOnly);
26
file.write(msg, qstrlen(msg));
// write to stderr
27
file.close();
28
}
29
//! [3]
30
31
32
#
if
0
33
//! [4]
34
CONFIG += console
35
//! [4]
36
#
endif
example
void example()
[5]
Definition
doc_src_groups.cpp:7
printError
void printError(const char *msg)
[3]
Definition
src_corelib_io_qfile.cpp:22
qtbase
src
corelib
doc
snippets
code
src_corelib_io_qfile.cpp
Generated on
for Qt by
1.14.0