[PyQt] popping up completion on QLineEdit focusIn and changing completer on user input

Sanjeev Kumar niceguysan at gmail.com
Fri Nov 1 09:39:00 GMT 2013


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.QCompleter.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.CaseInsensitive) 
    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 theQCompleter 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20131101/669f0e11/attachment-0001.html>


More information about the PyQt mailing list