【发布时间】:2021-01-22 18:12:02
【问题描述】:
如何限制 PyQt QCompleter 中显示的行数。例如,如果有 10 个匹配项,我将如何限制。这是我的代码:
from PyQt5.QtWidgets import *
from PyQt5 import QtCore
import sys
class Window(QWidget):
def __init__(self):
QWidget.__init__(self)
layout = QGridLayout()
self.setLayout(layout)
names = ["Apple", "Alps", "August", "Alpha", "Ate", "A""Berry", "Cherry" ]
completer = QCompleter(names)
self.lineedit = QLineEdit()
self.lineedit.setCompleter(completer)
layout.addWidget(self.lineedit, 0, 0)
app = QApplication(sys.argv)
screen = Window()
screen.show()
sys.exit(app.exec_())
我确实尝试过查看this link,但完全不明白。当我尝试设置模型时,我不断收到错误。
【问题讨论】:
标签: python python-3.x pyqt pyqt5 qcompleter