diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 091ee32a..fe894181 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -254,6 +254,18 @@ void WlanListItem::keyPressEvent(QKeyEvent *event) return QFrame::keyPressEvent(event); } +void WlanListItem::paintEvent(QPaintEvent *event) +{ + QPalette pal = this->palette(); + if (m_pwdLineEdit != nullptr) { + pal.setColor(QPalette::Base, pal.color(QPalette::Base)); + pal.setColor(QPalette::Text, pal.color(QPalette::Text)); + m_pwdLineEdit->setPalette(pal); + } + + return QWidget::paintEvent(event); +} + void WlanListItem::initWlanUI() { m_hasPwd = (m_wirelessNetItem.m_secuType.isEmpty() || m_wirelessNetItem.m_secuType == "") ? false : true; @@ -281,7 +293,6 @@ void WlanListItem::initWlanUI() m_pwdLineEdit = new KPasswordEdit(m_pwdFrame); m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH); m_pwdLineEdit->setProperty("needTranslucent", true); -// m_pwdLineEdit->setUseCustomPalette(true); m_pwdLineEdit->setClearButtonEnabled(false); //禁用ClearBtn按钮 m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); //打开输入法 // m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false); diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index ab28e729..d5443ee9 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -90,6 +90,7 @@ protected: void leaveEvent(QEvent *event); bool eventFilter(QObject *watched, QEvent *event); void keyPressEvent(QKeyEvent *event); + void paintEvent(QPaintEvent *event); Q_SIGNALS: void itemHeightChanged(const bool isExpanded, const QString &ssid);