From 517956733440bb5a005d950e54aac06ce3bc0213 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 11 Feb 2023 18:13:29 +0100 Subject: [PATCH] Use `QEnterEvent` for `QWidget::enterEvent` on Qt 6 (#4365) * fix: use concrete QEnterEvent on Qt 6 * chore: add changelog entry --- CHANGELOG.md | 1 + src/widgets/helper/Button.cpp | 6 +++++- src/widgets/helper/Button.hpp | 6 +++++- src/widgets/helper/ChannelView.cpp | 6 +++++- src/widgets/helper/ChannelView.hpp | 6 +++++- src/widgets/helper/NotebookTab.cpp | 4 ++++ src/widgets/helper/NotebookTab.hpp | 6 +++++- src/widgets/splits/Split.cpp | 6 +++++- src/widgets/splits/Split.hpp | 6 +++++- src/widgets/splits/SplitHeader.cpp | 4 ++++ src/widgets/splits/SplitHeader.hpp | 4 ++++ 11 files changed, 48 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ec22bbd..a17a6c718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Dev: Changed conan generator to [`CMakeDeps`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmakedeps.html) and [`CMakeToolchain`](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html). See PR for migration notes. (#4335) - Dev: Refactored 7TV EventAPI implementation. (#4342) - Dev: Don't rely on undocumented registry keys to find the default browser on Windows. (#4362) +- Dev: Use `QEnterEvent` for `QWidget::enterEvent` on Qt 6. (#4365) ## 2.4.0 diff --git a/src/widgets/helper/Button.cpp b/src/widgets/helper/Button.cpp index 4b86742ff..d1e92af97 100644 --- a/src/widgets/helper/Button.cpp +++ b/src/widgets/helper/Button.cpp @@ -217,7 +217,11 @@ void Button::fancyPaint(QPainter &painter) } } -void Button::enterEvent(QEvent *) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void Button::enterEvent(QEnterEvent * /*event*/) +#else +void Button::enterEvent(QEvent * /*event*/) +#endif { this->mouseOver_ = true; } diff --git a/src/widgets/helper/Button.hpp b/src/widgets/helper/Button.hpp index 79ca95767..cac8c532f 100644 --- a/src/widgets/helper/Button.hpp +++ b/src/widgets/helper/Button.hpp @@ -57,7 +57,11 @@ signals: protected: virtual void paintEvent(QPaintEvent *) override; - virtual void enterEvent(QEvent *) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent * /*event*/) override; +#else + void enterEvent(QEvent * /*event*/) override; +#endif virtual void leaveEvent(QEvent *) override; virtual void mousePressEvent(QMouseEvent *event) override; virtual void mouseReleaseEvent(QMouseEvent *event) override; diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 3a2c71db4..ac8b153c9 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1440,7 +1440,11 @@ void ChannelView::wheelEvent(QWheelEvent *event) } } -void ChannelView::enterEvent(QEvent *) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void ChannelView::enterEvent(QEnterEvent * /*event*/) +#else +void ChannelView::enterEvent(QEvent * /*event*/) +#endif { } diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 0d5e1b3e3..3fb47c04d 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -167,7 +167,11 @@ protected: void paintEvent(QPaintEvent *) override; void wheelEvent(QWheelEvent *event) override; - void enterEvent(QEvent *) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent * /*event*/) override; +#else + void enterEvent(QEvent * /*event*/) override; +#endif void leaveEvent(QEvent *) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 7d8bd0003..539d44263 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -674,7 +674,11 @@ void NotebookTab::mouseDoubleClickEvent(QMouseEvent *event) } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void NotebookTab::enterEvent(QEnterEvent *event) +#else void NotebookTab::enterEvent(QEvent *event) +#endif { this->mouseOver_ = true; diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 37cf1b3b6..36d622624 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -61,7 +61,11 @@ protected: virtual void mousePressEvent(QMouseEvent *event) override; virtual void mouseReleaseEvent(QMouseEvent *event) override; virtual void mouseDoubleClickEvent(QMouseEvent *event) override; - virtual void enterEvent(QEvent *) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else + void enterEvent(QEvent *event) override; +#endif virtual void leaveEvent(QEvent *) override; virtual void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index a55c2571d..0fd258025 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -822,7 +822,11 @@ void Split::resizeEvent(QResizeEvent *event) this->overlay_->setGeometry(this->rect()); } -void Split::enterEvent(QEvent *event) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void Split::enterEvent(QEnterEvent * /*event*/) +#else +void Split::enterEvent(QEvent * /*event*/) +#endif { this->isMouseOver_ = true; diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index 209930045..833bfffe4 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -105,7 +105,11 @@ protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; void resizeEvent(QResizeEvent *event) override; - void enterEvent(QEvent *event) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent * /*event*/) override; +#else + void enterEvent(QEvent * /*event*/) override; +#endif void leaveEvent(QEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override; diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 796992378..a7781119b 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -945,7 +945,11 @@ void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event) this->doubleClicked_ = true; } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void SplitHeader::enterEvent(QEnterEvent *event) +#else void SplitHeader::enterEvent(QEvent *event) +#endif { if (!this->tooltipText_.isEmpty()) { diff --git a/src/widgets/splits/SplitHeader.hpp b/src/widgets/splits/SplitHeader.hpp index 6b730703a..7e7d9e8c8 100644 --- a/src/widgets/splits/SplitHeader.hpp +++ b/src/widgets/splits/SplitHeader.hpp @@ -42,7 +42,11 @@ protected: void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *event) override; +#else void enterEvent(QEvent *event) override; +#endif void leaveEvent(QEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override;