From 3cd17fdb5aa1b1530b13255c7f6f845eac77a556 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Wed, 1 Jun 2022 17:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=BD=91=E7=BB=9C=E7=8A=B6=E6=80=81=E5=BA=95=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/netconnect/addnetbtn.cpp | 18 +++++++++++++----- plugins/netconnect/lanitem.cpp | 3 ++- plugins/wlanconnect/wlanitem.cpp | 18 ++++++++++++++---- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/plugins/netconnect/addnetbtn.cpp b/plugins/netconnect/addnetbtn.cpp index d0a14714..9235faec 100644 --- a/plugins/netconnect/addnetbtn.cpp +++ b/plugins/netconnect/addnetbtn.cpp @@ -13,9 +13,8 @@ AddNetBtn::AddNetBtn(QWidget *parent) : QPushButton(parent) this->setObjectName("this"); this->setMinimumSize(QSize(580, 60)); this->setMaximumSize(QSize(16777215, 60)); - this->setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); this->setProperty("useButtonPalette", true); - + this->setFlat(true); QHBoxLayout *addLyt = new QHBoxLayout; QLabel *iconLabel = new QLabel(); @@ -62,9 +61,18 @@ void AddNetBtn::paintEvent(QPaintEvent *event) QRect rect = this->rect(); QPainterPath path; - path.addRoundedRect (rect, RADIUS, RADIUS); - QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2); - path.addRect(temp_rect); + + //设置起点 + path.moveTo(rect.topLeft().x(), rect.topLeft().y()); + path.lineTo(rect.bottomLeft().x(), rect.bottomLeft().y() - RADIUS); + //绘制圆角 圆弧以外切圆的270度位置为起点,逆时针画圆弧运行90度结束 + path.arcTo(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 180, 90); + path.lineTo(rect.bottomRight().x() - RADIUS, rect.bottomRight().y()); + //画圆弧 + path.arcTo(QRect(QPoint(rect.bottomRight().x() - (RADIUS * 2), rect.bottomRight().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 270, 90); + path.lineTo(rect.topRight()); + path.lineTo(rect.topLeft()); + painter.drawPath(path); QPushButton::paintEvent(event); } diff --git a/plugins/netconnect/lanitem.cpp b/plugins/netconnect/lanitem.cpp index 5d33d983..0fac38e3 100644 --- a/plugins/netconnect/lanitem.cpp +++ b/plugins/netconnect/lanitem.cpp @@ -11,7 +11,8 @@ LanItem::LanItem(bool isAcitve, QWidget *parent) { this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); - setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); + this->setFlat(true); +// setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); mLanLyt->setSpacing(16); diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp index 5d1bbf3c..e45f2493 100644 --- a/plugins/wlanconnect/wlanitem.cpp +++ b/plugins/wlanconnect/wlanitem.cpp @@ -13,7 +13,7 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent) { this->setMinimumSize(550, 58); this->setProperty("useButtonPalette", true); - setStyleSheet("QPushButton:!checked{background-color: palette(base)}"); + this->setFlat(true); QHBoxLayout *mLanLyt = new QHBoxLayout(this); mLanLyt->setContentsMargins(16,0,16,0); mLanLyt->setSpacing(16); @@ -81,9 +81,19 @@ void WlanItem::paintEvent(QPaintEvent *event) painter.drawRect(rect); } else { QPainterPath path; - path.addRoundedRect (rect, RADIUS, RADIUS); - QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2); - path.addRect(temp_rect); +// path.addRoundedRect (rect, RADIUS, RADIUS); +// QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2); +// path.addRect(temp_rect); + //设置起点 + path.moveTo(rect.topLeft().x(), rect.topLeft().y()); + path.lineTo(rect.bottomLeft().x(), rect.bottomLeft().y() - RADIUS); + //绘制圆角 圆弧以外切圆的270度位置为起点,逆时针画圆弧运行90度结束 + path.arcTo(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 180, 90); + path.lineTo(rect.bottomRight().x() - RADIUS, rect.bottomRight().y()); + //画圆弧 + path.arcTo(QRect(QPoint(rect.bottomRight().x() - (RADIUS * 2), rect.bottomRight().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 270, 90); + path.lineTo(rect.topRight()); + path.lineTo(rect.topLeft()); painter.drawPath(path); } QPushButton::paintEvent(event);