Merhabalar, QGraphicsScene içine bir rect oluşturmak istiyorum fakat kodların hiç bir etkisi olmuyor.
Kodlar:
class NodeGraphicsScene(QGraphicsScene):
def __init__(self, parent=None):
super().__init__(parent)
self.sceneWidth, self.sceneHeight = 1000, 1000
self.setSceneRect(self.sceneWidth//2, self.sceneHeight//2, self.sceneWidth, self.sceneHeight)
self.setBackgroundBrush(QColor("#191919"))
class NodeEditorWindow(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Node Editor")
self.setMinimumSize(100, 100)
self.resize(800, 500)
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.layout)
self.scene = NodeGraphicsScene() #Ayrı oluşturduğum bir Class. Yukarıda var.
self.view = QGraphicsView()
self.view.setScene(self.scene)
self.layout.addWidget(self.view)
self.addRectNode()
self.show()
def addRectNode(self):
nodeBrush = QBrush(Qt.green)
outlinePen = QPen(Qt.black)
outlinePen.setWidth(2)
rect = self.scene.addRect("DENEME")
rect.setFlag(QGraphicsItem.ItemIsSelectable, True)
rect.setFlag(QGraphicsItem.ItemIsMovable, True)
print("Debug: Node Added")
if __name__ == "__main__":
app = QApplication(sys.argv)
root = NodeEditorWindow()
sys.exit(app.exec_())