qt5base-lts/tests/manual/wasm/eventloop/dialog_exec/main.cpp
Lucie Gérard 05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00

49 lines
1.3 KiB
C++

// 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();
}