From 2f2ee6571e9ce784db0488ade60816f09bd7448c Mon Sep 17 00:00:00 2001 From: SineStriker <trueful@163.com> Date: 周三, 27 12月 2023 01:56:47 +0800 Subject: [PATCH] Finish customize system button pos for QtWidgets --- examples/shared/widgetframe/windowbar.cpp | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/shared/widgetframe/windowbar.cpp b/examples/shared/widgetframe/windowbar.cpp index fba9a49..51a2d3e 100644 --- a/examples/shared/widgetframe/windowbar.cpp +++ b/examples/shared/widgetframe/windowbar.cpp @@ -1,5 +1,5 @@ -#include "WindowBar.h" -#include "WindowBar_p.h" +#include "windowbar.h" +#include "windowbar_p.h" #include <QtCore/QDebug> #include <QtGui/QtEvents> @@ -12,13 +12,12 @@ autoIcon = false; } - WindowBarPrivate::~WindowBarPrivate() { - } + WindowBarPrivate::~WindowBarPrivate() = default; void WindowBarPrivate::init() { Q_Q(WindowBar); layout = new QHBoxLayout(); - layout->setMargin(0); + layout->setContentsMargins(QMargins()); layout->setSpacing(0); for (int i = IconButton; i <= CloseButton; ++i) { insertDefaultSpace(i); @@ -54,8 +53,7 @@ WindowBar::WindowBar(QWidget *parent) : WindowBar(*new WindowBarPrivate(), parent) { } - WindowBar::~WindowBar() { - } + WindowBar::~WindowBar() = default; QMenuBar *WindowBar::menuBar() const { Q_D(const WindowBar); @@ -248,23 +246,26 @@ QLabel *label = titleLabel(); QAbstractButton *maxBtn = maxButton(); switch (event->type()) { - case QEvent::WindowIconChange: + case QEvent::WindowIconChange: { if (d_ptr->autoIcon && iconBtn) { iconBtn->setIcon(w->windowIcon()); iconChanged(w->windowIcon()); } break; - case QEvent::WindowTitleChange: + } + case QEvent::WindowTitleChange: { if (d_ptr->autoTitle && label) { label->setText(w->windowTitle()); titleChanged(w->windowTitle()); } break; - case QEvent::WindowStateChange: + } + case QEvent::WindowStateChange: { if (maxBtn) { maxBtn->setChecked(w->isMaximized()); } break; + } default: break; } -- Gitblit v1.9.1