def pathFromIndex(self, index): path = QCompleter.pathFromIndex(self, index) string = str(self.widget().text()) split = string.split(self.punctuation) if len(split) > 1: path = "%s, %s" % (",".join(split[:-1]), path) return path
def pathFromIndex(self, index): # 返回值为填充到框中的文本 path = QCompleter.pathFromIndex(self, index) # 当前在弹出窗口选择的文本 print(path) lst = str(self.widget().text()).split(',') if len(lst) > 1: path = '%s, %s' % (', '.join(lst[:-1]), path) return path
def pathFromIndex(self, index): path = QCompleter.pathFromIndex(self, index) lst = str(self.widget().text()).split(',') if len(lst) > 1: path = '%s, %s' % (','.join(lst[:-1]), path) return path
def pathFromIndex(self, index): """Add texts instead of replace.""" path = QCompleter.pathFromIndex(self, index) lst = str(self.widget().text()).split(' ') if len(lst) > 1: path = '%s %s' % (' '.join(lst[:-1]), path) return path
def pathFromIndex(self, index): path = QCompleter.pathFromIndex(self, index) words = self.widget().text().split("-") if len(words) > 1: path = "{}-{}".format("-".join(words[:-1]), path) return path