提交 15a9d19c 编写于 作者: 之一Yo's avatar 之一Yo

fixes #200

上级 b040d53f
# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout
from qfluentwidgets import LineEdit, PushButton, TextEdit
from qfluentwidgets import LineEdit, PushButton, SearchLineEdit
class Demo(QWidget):
def __init__(self):
super().__init__()
self.lineEdit = LineEdit(self)
self.button = PushButton('按钮', self)
self.textEdit = TextEdit(self)
self.hBoxLayout = QHBoxLayout(self)
self.lineEdit = SearchLineEdit(self)
self.button = PushButton('Search', self)
self.resize(500, 500)
self.textEdit.move(110, 200)
self.lineEdit.move(110, 50)
self.button.move(320, 52)
self.resize(400, 400)
self.hBoxLayout.setAlignment(Qt.AlignCenter)
self.hBoxLayout.addWidget(self.lineEdit, 0, Qt.AlignCenter)
self.hBoxLayout.addWidget(self.button, 0, Qt.AlignCenter)
self.lineEdit.resize(200, 33)
self.lineEdit.setFixedSize(200, 33)
self.lineEdit.setClearButtonEnabled(True)
self.lineEdit.setPlaceholderText('Search icon')
if __name__ == '__main__':
......
......@@ -2,7 +2,7 @@
from PyQt5.QtCore import Qt
from PyQt5.QtDesigner import QPyDesignerCustomWidgetPlugin
from qfluentwidgets import SpinBox, DoubleSpinBox, TextEdit, TimeEdit, DateTimeEdit, LineEdit, PlainTextEdit, DateEdit
from qfluentwidgets import SpinBox, DoubleSpinBox, TextEdit, TimeEdit, DateTimeEdit, LineEdit, PlainTextEdit, DateEdit, SearchLineEdit
from plugin_base import PluginBase
......@@ -26,6 +26,19 @@ class LineEditPlugin(TextPlugin, QPyDesignerCustomWidgetPlugin):
return "LineEdit"
class SearchLineEditPlugin(TextPlugin, QPyDesignerCustomWidgetPlugin):
""" Search line edit plugin """
def createWidget(self, parent):
return SearchLineEdit(parent)
def icon(self):
return super().icon("IconElement")
def name(self):
return "SearchLineEdit"
class TextEditPlugin(TextPlugin, QPyDesignerCustomWidgetPlugin):
""" Text edit plugin """
......
......@@ -111,12 +111,13 @@ class LineEdit(QLineEdit):
painter.setRenderHints(QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
m = self.contentsMargins()
path = QPainterPath()
w, h = self.width(), self.height()
path.addRoundedRect(QRectF(0, h-10, w, 10), 5, 5)
w, h = self.width()-m.left()-m.right(), self.height()
path.addRoundedRect(QRectF(m.left(), h-10, w, 10), 5, 5)
rectPath = QPainterPath()
rectPath.addRect(0, h-10, w, 8)
rectPath.addRect(m.left(), h-10, w, 8)
path = path.subtracted(rectPath)
painter.fillPath(path, themeColor())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册