zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.61k stars 541 forks source link

QCompleter 检索导致页面卡顿 #523

Closed witech-king closed 1 year ago

witech-king commented 1 year ago

Describe the bug QCompleter过多导致检索卡顿

Environment 环境信息

To Reproduce items长度为3866出现卡顿要8s 耗时代码\qfluentwidgets\components\widgets\line_edit setCompletion

 for i in items:
     self.addAction(QAction(i, triggered=lambda c, x=i: self.lineEdit.setText(x)))

Code 最小复现代码

# Minimum code to reproduce the error
class CSearchLineedit(SearchLineEdit):

    def __init__(self, parent=None):
        super(CSearchLineedit, self).__init__(parent)
        self.setClearButtonEnabled(True)

    def set_completer(self, search_info_list):
        search_completer = QCompleter(search_info_list, self)
        search_completer.setCaseSensitivity(Qt.CaseInsensitive)
        search_completer.setFilterMode(Qt.MatchContains)
        self.setCompleter(search_completer)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

witech-king commented 1 year ago

复现视频

https://github.com/zhiyiYo/PyQt-Fluent-Widgets/assets/137036346/2ca6707b-c7b1-4733-bb1b-6714c6440acf

zhiyiYo commented 1 year ago

目前已修复此问题,延迟为 0