I'm trying to make a node based interface, and I want to make a Value node with a QLineEdit to be editable and I want the user to be able to move the node, but It's not working.
The node is displayed and is movable but the QLineEdit is not editable.
Here's a minimal reproducible example, the problem: the user can't interact with the widgets inside the graphic element.
class TestLineEdit(QGraphicsRectItem):
def __init__(self, width: float, height: float, parent=None):
super().__init__(parent)
self.groupBox = QGroupBox("Contact Details")
self.numberLabel = QLabel("Telephone number")
self.numberEdit = QLineEdit()
self.layout = QFormLayout(self.groupBox)
self.layout.addRow(self.numberLabel, self.numberEdit)
self.proxy_widget = QGraphicsProxyWidget(self)
self.proxy_widget.setWidget(self.groupBox)
def boundingRect(self):
return QRectF(self.rect())
def paint(self, painter, option, widget=None):
pass
test_line_edit: TestLineEdit = TestLineEdit(100, 100)
test_group = QGraphicsItemGroup()
test_group.addToGroup(test_line_edit)
test_group.setFlag(QGraphicsItem.ItemIsMovable, enabled=True)
scene.addItem(test_group)