Qt 6.x
The Qt SDK
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#ifndef QT_NO_TEMPORARYFILE
18
21
22class Q_CORE_EXPORT QTemporaryFile : public QFile
23{
24#ifndef QT_NO_QOBJECT
26#endif
27 Q_DECLARE_PRIVATE(QTemporaryFile)
28
29public:
31 explicit QTemporaryFile(const QString &templateName);
32#ifndef QT_NO_QOBJECT
33 explicit QTemporaryFile(QObject *parent);
34 QTemporaryFile(const QString &templateName, QObject *parent);
35#endif
37
38 bool autoRemove() const;
39 void setAutoRemove(bool b);
40
41 // ### Hides open(flags)
42 bool open() { return open(QIODevice::ReadWrite); }
43
44 QString fileName() const override;
45 QString fileTemplate() const;
46 void setFileTemplate(const QString &name);
47
48 // Hides QFile::rename
49 bool rename(const QString &newName);
50
52 { QFile file(fileName); return createNativeFile(file); }
53 static QTemporaryFile *createNativeFile(QFile &file);
54
55protected:
56 bool open(OpenMode flags) override;
57
58private:
59 friend class QFile;
60 friend class QLockFilePrivate;
61 Q_DISABLE_COPY(QTemporaryFile)
62};
63
64#endif // QT_NO_TEMPORARYFILE
65
67
68#endif // QTEMPORARYFILE_H
\inmodule QtCore
Definition qfile.h:93
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:881
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
Definition qfile.cpp:277
bool rename(const QString &newName)
Renames the file currently specified by fileName() to newName.
Definition qfile.cpp:533
friend class QTemporaryFile
Definition qfile.h:323
\inmodule QtCore
Definition qobject.h:90
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore \reentrant
static QTemporaryFile * createNativeFile(const QString &fileName)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool open()
A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the d...
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLbitfield flags
GLuint name
#define Q_OBJECT
QFile file
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent