PyQT5 - How to use QCompleter, QGIS Plugin
Unsolved
Qt for Python
-
I'm trying to use QCompleter to get something like in the image. The code seems pretty simple, but in my dialog nothing happens. Is there some problem in this code? The dialog is created using Qt Designer.
import sys from PyQt5.QtWidgets import QAction, QFileDialog, QApplication, QWidget, QVBoxLayout, QLineEdit, QCompleter # def run(self): if self.first_start == True: self.first_start = False self.dlg = SelectFeatureDialog() strList = ['Python', 'PyQt5', 'Qt', 'QML'] completer = QCompleter(strList) self.dlg.lineEdit.setCompleter(completer) self.dlg.show() result = self.dlg.exec_() if result: pass
EDIT: are there some errors in these settings?
-
Hi,
This example works as expected:
import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QLineEdit, QCompleter, QDialog, QVBoxLayout if __name__ == "__main__": app = QApplication(sys.argv) line_edit = QLineEdit() completer = QCompleter(["Apple", "Alps"]) completer.setCaseSensitivity(Qt.CaseInsensitive) line_edit.setCompleter(completer) dialog = QDialog() layout = QVBoxLayout(dialog) layout.addWidget(line_edit) dialog.show() sys.exit(app.exec_())
What version of PyQt5 are you using ?