From 1e24fbd300337fa026b65ff252d28745d8aa4413 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Tue, 19 Dec 2023 09:38:22 +0800 Subject: [PATCH] add doubleclick titlebar --- src/titlebar.cpp | 9 +++++++++ src/titlebar.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/titlebar.cpp b/src/titlebar.cpp index b9f217d..5736a7a 100644 --- a/src/titlebar.cpp +++ b/src/titlebar.cpp @@ -146,3 +146,12 @@ void TitleBar::setGoHomeBtn(bool isable) } } + +void TitleBar::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + toggleMaximize(); + } + + QWidget::mouseDoubleClickEvent(event); +} diff --git a/src/titlebar.h b/src/titlebar.h index cf37e7c..9b4b70d 100644 --- a/src/titlebar.h +++ b/src/titlebar.h @@ -26,6 +26,8 @@ public: signals: void gohomesignal(); // 声明自定义信号 void savePathUpdate(const QString& filePath); +protected: + void mouseDoubleClickEvent(QMouseEvent *event); private: bool m_ismaximized; QToolButton *m_optionbtn = nullptr; // 菜单选项