Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQT5 - How to use QCompleter, QGIS Plugin
Forum Updated to NodeBB v4.3 + New Features

PyQT5 - How to use QCompleter, QGIS Plugin

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 523 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bemlun
    wrote on last edited by bemlun
    #1

    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.
    alt text

    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?
    Annotazione 2019-11-29 110954.jpg

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved