Debian Codegraph @

tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 #include <QtGui/qguiapplication.h>
5 #include <QtGui/qevent.h>
6
7 #include <QtCore/qfile.h>
8
9 struct MyApplication : public QGuiApplication
10 {
11 MyApplication(int& argc, char** argv)
12 : QGuiApplication(argc, argv)
13 {}
14
15 bool event(QEvent * event) override
16 {
17 if (event->type() == QEvent::FileOpen) {
18 QFileOpenEvent* ev = static_cast<QFileOpenEvent *>(event);
19 QFile file(ev->file());
20 bool ok = file.open(QFile::Append | QFile::Unbuffered);
21 if (ok)
22 file.write(QByteArray("+external"));
23 return true;
24 } else {
25 return QGuiApplication::event(event);
26 }
27 }
28 };
29
30 int main(int argc, char *argv[])
31 {
32 MyApplication a(argc, argv);
33 a.sendPostedEvents(&a, QEvent::FileOpen);
34 return 0;
35 }