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
qtemporaryfile.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTEMPORARYFILE_H
5#define QTEMPORARYFILE_H
6
7#include <QtCore/qiodevice.h>
8#include <QtCore/qfile.h>
9
10#ifdef open
11#error qtemporaryfile.h must be included before any header file that defines open
12#endif
13
15
16
17#if QT_CONFIG(temporaryfile)
18
19class QTemporaryFilePrivate;
21
22class Q_CORE_EXPORT QTemporaryFile : public QFile
23{
24#ifndef QT_NO_QOBJECT
26#endif
27 Q_DECLARE_PRIVATE(QTemporaryFile)
28
29public:
30 QTemporaryFile();
31 explicit QTemporaryFile(const QString &templateName);
32#ifndef QT_NO_QOBJECT
33 explicit QTemporaryFile(QObject *parent);
34 QTemporaryFile(const QString &templateName, QObject *parent);
35
36# if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
38 explicit QTemporaryFile(const std::filesystem::path &templateName, QObject *parent = nullptr)
39 : QTemporaryFile(QtPrivate::fromFilesystemPath(templateName), parent)
40 {
41 }
42# endif // QT_CONFIG(cxx17_filesystem)
43#endif // !QT_NO_QOBJECT
44
45 ~QTemporaryFile();
46
47 bool autoRemove() const;
48 void setAutoRemove(bool b);
49
50 // ### Hides open(flags)
52
53 QString fileName() const override;
54 QString fileTemplate() const;
55 void setFileTemplate(const QString &name);
56#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
58 void setFileTemplate(const std::filesystem::path &name)
59 {
60 return setFileTemplate(QtPrivate::fromFilesystemPath(name));
61 }
62#endif // QT_CONFIG(cxx17_filesystem)
63
64 // Hides QFile::rename
65 bool rename(const QString &newName);
66
67#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
69 bool rename(const std::filesystem::path &newName)
70 {
71 return rename(QtPrivate::fromFilesystemPath(newName));
72 }
73#endif // QT_CONFIG(cxx17_filesystem)
74
75 inline static QTemporaryFile *createNativeFile(const QString &fileName)
76 { QFile file(fileName); return createNativeFile(file); }
77 static QTemporaryFile *createNativeFile(QFile &file);
78
79#if QT_CONFIG(cxx17_filesystem) || defined(Q_QDOC)
81 static QTemporaryFile *createNativeFile(const std::filesystem::path &fileName)
82 {
84 return createNativeFile(file);
85 }
86#endif // QT_CONFIG(cxx17_filesystem)
87
88protected:
89 bool open(OpenMode flags) override;
90
91private:
92 friend class QFile;
93 friend class QLockFilePrivate;
94 Q_DISABLE_COPY(QTemporaryFile)
95};
96
97#endif // QT_CONFIG(temporaryfile)
98
100
101#endif // QTEMPORARYFILE_H
\inmodule QtCore
Definition qfile.h:93
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
#define Q_WEAK_OVERLOAD
#define QFILE_MAYBE_NODISCARD
Definition qfiledevice.h:26
GLboolean GLboolean GLboolean b
GLbitfield flags
GLuint name
#define Q_OBJECT
QFile file
[0]
file open(QIODevice::ReadOnly)