example: Added --blocks-close-event

Makes dock widget #0 reject the close event, meaning it won't close.

(cherry-picked from commit 21765efbac)
This commit is contained in:
Sergio Martins
2022-06-19 11:18:02 +01:00
parent f8b1745c68
commit 198bd60565
5 changed files with 36 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
#include <QDebug>
#include <QFile>
#include <QLineEdit>
#include <QCloseEvent>
static QHash<QString, QImage> s_images; /// clazy:exclude=non-pod-global-static
@@ -70,6 +71,20 @@ void MyWidget::drawLogo(QPainter &p)
p.drawImage(targetLogoRect, m_logo, m_logo.rect());
}
void MyWidget::blockCloseEvent()
{
m_blocksCloseEvent = true;
}
void MyWidget::closeEvent(QCloseEvent *ev)
{
if (m_blocksCloseEvent) {
ev->ignore();
} else {
QWidget::closeEvent(ev);
}
}
MyWidget1::MyWidget1(MyWidget::QWidget *parent)
: MyWidget(QStringLiteral(":/assets/triangles.png"), QStringLiteral(":/assets/KDAB_bubble_white.png"), parent)
{