mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 09:15:23 +08:00
qt 6.5.1 original
This commit is contained in:
12
tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt
Normal file
12
tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
qt_internal_add_manual_test(dialog_exec
|
||||
GUI
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
48
tests/manual/wasm/eventloop/dialog_exec/main.cpp
Normal file
48
tests/manual/wasm/eventloop/dialog_exec/main.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
#include <QtGui>
|
||||
#include <QtWidgets>
|
||||
|
||||
// This example show how calling QDialog::exec() shows the dialog,
|
||||
// but does not return.
|
||||
|
||||
class ClickWindow: public QRasterWindow
|
||||
{
|
||||
public:
|
||||
ClickWindow() {
|
||||
qDebug() << "ClickWindow constructor";
|
||||
}
|
||||
|
||||
~ClickWindow() {
|
||||
qDebug() << "ClickWindow destructor";
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *ev) override {
|
||||
QPainter p(this);
|
||||
p.fillRect(ev->rect(), QColorConstants::Svg::deepskyblue);
|
||||
p.drawText(50, 100, "Application has started. See the developer tools console for debug output");
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *) override {
|
||||
qDebug() << "mousePressEvent(): calling QMessageBox::exec()";
|
||||
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText("Hello! This is a message box.");
|
||||
connect(&messageBox, &QMessageBox::buttonClicked, [](QAbstractButton *button) {
|
||||
qDebug() << "Button Clicked" << button;
|
||||
});
|
||||
messageBox.exec(); // <-- does not return
|
||||
|
||||
qDebug() << "mousePressEvent(): done"; // <--- will not be printed
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
ClickWindow window;
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
Reference in New Issue
Block a user