[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] Drawing lines in PyQt in real time
From: sw33tz <nyavuz.nm20 () gmail ! com>
Date: 2016-04-24 12:25:23
Message-ID: 1461500723320-5189233.post () n6 ! nabble ! com
[Download RAW message or body]
I'm making an application and I want to connect certain items in the
QGraphicsScene by using lines. I want this done in real time, so while I'm
holding the mouse down and trying to draw the line I want to see the line
being drawn. I've written some code to allow this but the problem with this
code is that it keeps on clearing everything and I dont know a way around
this. Any help would be much appreciated.
class graphicsScene(QtGui.QGraphicsScene, QtGui.QWidget):
self.pen = QtGui.QPen(QtCore.Qt.black, 3, QtCore.Qt.SolidLine)
def mousePressEvent(self, event):
if connectLine_cs == 1:
self.cursorStartPosition = event.scenePos()
self.start =
QtCore.QPoint(self.cursorStartPosition.x(),self.cursorStartPosition.y())
def mouseMoveEvent(self, event):
if connectLine_cs == 1:
self.cursorCurrentPosition = event.scenePos()
current =
QtCore.QPointF(self.cursorCurrentPosition.x(),self.cursorCurrentPosition.y())
self.clear()
link = QtGui.QGraphicsLineItem(QtCore.QLineF(self.start,
current))
link.setPen(self.pen)
self.addItem(link)
--
View this message in context: \
http://python.6.x6.nabble.com/Drawing-lines-in-PyQt-in-real-time-tp5189233.html Sent \
from the PyQt mailing list archive at Nabble.com. \
_______________________________________________ PyQt mailing list \
PyQt@riverbankcomputing.com https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic