PDA

View Full Version : popping up completion on QLineEdit focusIn and changing completer on user input



krystosan
1st November 2013, 10:36
I have data coming from two places one by this


def __pathsList(self):
defaultList = self.xmlDataObj.xmlData().values()
completerList = QtCore.QStringList()
for i in defaultList:
completerList.append(QtCore.QString(i))
lineEditCompleter = QtGui.QCompleter(completerList)
# lineEditCompleter.setCompletionMode(QtGui.QComplet er.UnfilteredPopupCompletion)
self.addPathEdit.setCompleter(lineEditCompleter)
and second by


def __dirCompleter(self):
# completer = TagsCompleter(self.addPathEdit, self.xmlDataObj.xmlData().values())
dirModel = QtGui.QFileSystemModel()
dirModel.setRootPath(QtCore.QDir.currentPath())
dirModel.setFilter(QtCore.QDir.AllDirs | QtCore.QDir.NoDotAndDotDot | QtCore.QDir.Files)
dirModel.setNameFilterDisables(0)
completer = QtGui.QCompleter(dirModel,self)
completer.setModel(dirModel)
print dir(completer)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensi tive)
self.addPathEdit.setCompleter(completer)

I want the first method to execute when the QLineEdit is in focus, but the second one to execute when user types "/" for OSx or Linux or single alphabet for windows users.

what I do not know is how to show the list right away when the QLineEdit is in focus but instead the QCompleter popups the list on typing "/" when I want when the user enters "/" then the second methods does the QCompleteion for dirCompletion .

Any help will be greatly appreciated,
Regards