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
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
6QDir::setCurrent("/tmp");
7file.setFileName("readme.txt");
8QDir::setCurrent("/home");
9file.open(QIODevice::ReadOnly); // opens "/home/readme.txt" under Unix
11
12
14#include <stdio.h>
15
16void printError(const char* msg)
17{
18 QFile file;
20 file.write(msg, qstrlen(msg)); // write to stderr
21 file.close();
22}
24
25
27CONFIG += console
static bool setCurrent(const QString &path)
Sets the application's current working directory to path.
Definition qdir.cpp:2030
void close() override
Calls QFileDevice::flush() and closes the file.
\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
void setFileName(const QString &name)
Sets the name of the file.
Definition qfile.cpp:302
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
size_t qstrlen(const char *str)
QFile file
[0]
void printError(const char *msg)
[0]