From fa6761afbf8c2658782e0c7fc5d51063679b7ae4 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Mon, 2 Dec 2019 20:14:22 +0100 Subject: [PATCH] gr-fosphor/qt: Qt5 - Track visibility of the widget When not visible, doing GL operations is not supported Signed-off-by: Sylvain Munaut --- lib/QGLSurface.cc | 13 +++++++++++++ lib/QGLSurface.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/QGLSurface.cc b/lib/QGLSurface.cc index 7abdcd3..3c588ec 100644 --- a/lib/QGLSurface.cc +++ b/lib/QGLSurface.cc @@ -40,6 +40,19 @@ QGLSurface::QGLSurface(QWidget *parent, qt_sink_c_impl *block) this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } + +void +QGLSurface::hideEvent(QHideEvent *he) +{ + this->d_block->cb_visibility(this->isVisible()); +} + +void +QGLSurface::showEvent(QShowEvent *he) +{ + this->d_block->cb_visibility(this->isVisible()); +} + void QGLSurface::paintEvent(QPaintEvent *pe) { diff --git a/lib/QGLSurface.h b/lib/QGLSurface.h index 65afd8a..a10b2a1 100644 --- a/lib/QGLSurface.h +++ b/lib/QGLSurface.h @@ -38,6 +38,8 @@ namespace gr { QThread *d_gui_thread; protected: + void hideEvent(QHideEvent *he); + void showEvent(QShowEvent *he); void paintEvent(QPaintEvent *pe); void resizeEvent(QResizeEvent *re); void keyPressEvent(QKeyEvent *ke);