class LineEditDialog(QDialog): def __init__(self, parent=None): super(LineEditDialog, self).__init__() self.value = None vbox = QVBoxLayout(self) # combo box model = QtGui.QStandardItemModel(self) for elm in rospy.get_param_names(): model.setItem(model.rowCount(), 0, QtGui.QStandardItem(elm)) self.combo_box = QComboBox(self) self.line_edit = QLineEdit() self.combo_box.setLineEdit(self.line_edit) self.combo_box.setCompleter(QCompleter()) self.combo_box.setModel(model) self.combo_box.completer().setModel(model) self.combo_box.lineEdit().setText('') vbox.addWidget(self.combo_box) # button button = QPushButton() button.setText("Done") button.clicked.connect(self.buttonCallback) vbox.addWidget(button) self.setLayout(vbox) def buttonCallback(self, event): self.value = self.line_edit.text() self.close()
widget = QWidget(mw) layout = QVBoxLayout(widget) edit = QLineEdit() edit_completer = TopicCompleter(edit) edit_completer.update_topics(topic_completer_node) # edit_completer.setCompletionMode(QCompleter.InlineCompletion) edit.setCompleter(edit_completer) combo = QComboBox() combo.setEditable(True) combo_completer = TopicCompleter(combo) combo_completer.update_topics(topic_completer_node) # combo_completer.setCompletionMode(QCompleter.InlineCompletion) combo.lineEdit().setCompleter(combo_completer) model_tree = QTreeView() model_tree.setModel(combo_completer.model()) model_tree.expandAll() for column in range(combo_completer.model().columnCount()): model_tree.resizeColumnToContents(column) completion_tree = QTreeView() completion_tree.setModel(combo_completer.completionModel()) completion_tree.expandAll() for column in range(combo_completer.completionModel().columnCount()): completion_tree.resizeColumnToContents(column) layout.addWidget(model_tree) layout.addWidget(completion_tree)