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
7void 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
22void 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]
34CONFIG += console
35//! [4]
36#endif
void example()
[5]
void printError(const char *msg)
[3]