mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
qt 6.5.1 original
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qfileopeneventexternal Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(qfileopeneventexternal
|
||||
GUI
|
||||
SOURCES
|
||||
qfileopeneventexternal.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
)
|
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtGui>
|
||||
#include <QEvent>
|
||||
|
||||
struct MyApplication : public QGuiApplication
|
||||
{
|
||||
MyApplication(int& argc, char** argv)
|
||||
: QGuiApplication(argc, argv)
|
||||
{}
|
||||
|
||||
bool event(QEvent * event) override
|
||||
{
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
QFileOpenEvent* ev = static_cast<QFileOpenEvent *>(event);
|
||||
QFile file;
|
||||
bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered);
|
||||
if (ok)
|
||||
file.write(QByteArray("+external"));
|
||||
return true;
|
||||
} else {
|
||||
return QGuiApplication::event(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MyApplication a(argc, argv);
|
||||
a.sendPostedEvents(&a, QEvent::FileOpen);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user