I have Create Menu in QTabelWidget using QMenu And for data entey in table I have used QlineEdit. While I Type in QLineEdit Qmenu lose focus and hide. So How can I Get make such menu which stays while I type in QEditLine.
self.linedit_in_table = QLineEdit(self.parent.Order_tabel)
self.linedit_in_table.contextMenuEvent
productWiget = QWidget()
productMenuWiget = Ui_ProductMenu()
productMenuWiget.setupUi(productWiget)
product_menu = QMenu(self.grand_parent)
widegetMenu = QWidgetAction(product_menu)
widegetMenu.setDefaultWidget(productWiget)
product_menu.addAction(widegetMenu)
#self.linedit_in_table.setFocusPolicy(Qt.StrongFocus)
self.parent.Order_tabel.setCellWidget(row, 1, self.linedit_in_table)
self.linedit_in_table.setFocus(Qt.OtherFocusReason)
product_menu.popup(self.parent.Order_tabel.mapToGlobal(QPoint(self.parent.Order_tabel.columnViewportPosition(1)+2,self.parent.Order_tabel.rowViewportPosition(row) +55)))
product_menu.setVisible(True)
self.linedit_in_table.textEdited.connect(lambda : [product_menu.setVisible(True), self.linedit_in_table.setFocus(Qt.OtherFocusReason)])
For tables and trees, the best way is to subclass a QItemDelegate and setting a QLineEdit with a Completer inside.