How can I limit the number of rows that are displayed in a PyQt QCompleter. For example, if there are 10 matches, how would I limit. This is my code:
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_())
I did try looking this link, but didn't understand it at all. When I tried to set the model, I kept getting errors.
question from:
https://stackoverflow.com/questions/65850537/limit-number-of-rows-in-pyqt-qcompleter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…