How to add a QCompleter to a Qtreeview
-
Hello, good evening. I have a small application that is used to add tasks to be done, and for this I use a QTreeview. Now I want to add word autocompletion using the QCompleter class, but I haven’t been able to do so. Could you please help me?
Below is some of the code I have written so far.class Por_Hacer(QTreeView): def __init__(self): super().__init__() self.setStyleSheet("background-color:#FF313131;color:white;font:bold 16px;border:None;") completar=["ABB","auto","avellana","asturia"] completer = QCompleter(completar) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(QFileSystemModel(completer)) self.header().hide() self.setAnimated(True) self.my_model=QStandardItemModel(self,completer) self.setModel(self.my_model) -
Hello, good evening. I have a small application that is used to add tasks to be done, and for this I use a QTreeview. Now I want to add word autocompletion using the QCompleter class, but I haven’t been able to do so. Could you please help me?
Below is some of the code I have written so far.class Por_Hacer(QTreeView): def __init__(self): super().__init__() self.setStyleSheet("background-color:#FF313131;color:white;font:bold 16px;border:None;") completar=["ABB","auto","avellana","asturia"] completer = QCompleter(completar) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(QFileSystemModel(completer)) self.header().hide() self.setAnimated(True) self.my_model=QStandardItemModel(self,completer) self.setModel(self.my_model)@electric-dev said in How to add a QCompleter to a Qtreeview:
completar=["ABB","auto","avellana","asturia"] completer = QCompleter(completar) ... completer.setModel(QFileSystemModel(completer)) ... self.my_model=QStandardItemModel(self,completer) self.setModel(self.my_model)These three sections of code are mutually incompatible. QCompleter supports a single model at a time.
In addition, the completer needs to be set on an input widget such as QLineEdit, or queried as described in the documentation.