Object
::connect: No such
slot Main
::mousePress(QMouseEvent,
int,
int)Object::connect: (receiver name: 'MainWindow')
Object
::connect: No such
slot Main
::mouseMove(QMouseEvent,
int,
int)Object::connect: (receiver name: 'MainWindow')
Object
::connect: No such
slot Main
::mouseRelease(QMouseEvent,
int,
int)Object::connect: (receiver name: 'MainWindow')
Object::connect: No such slot Main::mousePress(QMouseEvent,int,int)
Object::connect: (receiver name: 'MainWindow')
Object::connect: No such slot Main::mouseMove(QMouseEvent,int,int)
Object::connect: (receiver name: 'MainWindow')
Object::connect: No such slot Main::mouseRelease(QMouseEvent,int,int)
Object::connect: (receiver name: 'MainWindow')
To copy to clipboard, switch view to plain text mode
def mousePressEvent(self, event):
# emitir o sinal
self.emit(SIGNAL('mousePressEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
def mouseMoveEvent(self, event):
# emitir o sinal
self.emit(SIGNAL('mouseMoveEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
def mouseReleaseEvent(self, event):
self.emit(SIGNAL('mouseReleaseEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
def mousePressEvent(self, event):
# emitir o sinal
self.emit(SIGNAL('mousePressEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
def mouseMoveEvent(self, event):
# emitir o sinal
self.emit(SIGNAL('mouseMoveEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
def mouseReleaseEvent(self, event):
self.emit(SIGNAL('mouseReleaseEvent(int, int, QMouseEvent)'),
event.pos().x(), event.pos().y(), event)
To copy to clipboard, switch view to plain text mode
self.connect(
self.view, SIGNAL('mousePressEvent(QMouseEvent, int, int)'),
self, SLOT('mousePress(QMouseEvent, int, int)'))
self.connect(
self.view, SIGNAL('mouseMoveEvent(QMouseEvent, int, int)'),
self, SLOT('mouseMove(QMouseEvent, int, int)'))
self.connect(
self.view, SIGNAL('mouseReleaseEvent(QMouseEvent, int, int)'),
self, SLOT('mouseRelease(QMouseEvent, int, int)'))
...
def mousePress(self, event, x, y):
if (self.desLinha):
self.
inicio = self.
fim = self.
view.
mapToScene(QPoint(x,y
));
print "%dx %dy" % (x, y)
self.cena.addItem(self.linha)
def mouseMove(self, event, x, y):
if (self.desLinha):
self.
fim = self.
view.
mapToScene(QPoint(x,y
)) self.
linha.
setLine(QLineF(self.
inicio, self.
fim))
def mouseRelease(self, event, x, y):
if (self.desLinha):
self.
fim = self.
view.
mapToScene(QPoint(x,y
)) self.
linha.
setLine(QLineF(self.
inicio, self.
fim))
self.connect(
self.view, SIGNAL('mousePressEvent(QMouseEvent, int, int)'),
self, SLOT('mousePress(QMouseEvent, int, int)'))
self.connect(
self.view, SIGNAL('mouseMoveEvent(QMouseEvent, int, int)'),
self, SLOT('mouseMove(QMouseEvent, int, int)'))
self.connect(
self.view, SIGNAL('mouseReleaseEvent(QMouseEvent, int, int)'),
self, SLOT('mouseRelease(QMouseEvent, int, int)'))
...
@pyqtSlot(QMouseEvent, int, int)
def mousePress(self, event, x, y):
if (self.desLinha):
self.inicio = self.fim = self.view.mapToScene(QPoint(x,y));
self.linha = QGraphicsLineItem(QLineF(self.inicio, self.fim))
self.linha.setFlags(QGraphicsItem.ItemIsMovable)
print "%dx %dy" % (x, y)
self.cena.addItem(self.linha)
QGraphicsView.mousePressEvent(event)
@pyqtSlot(QMouseEvent, int, int)
def mouseMove(self, event, x, y):
if (self.desLinha):
self.fim = self.view.mapToScene(QPoint(x,y))
self.linha.setLine(QLineF(self.inicio, self.fim))
QGraphicsView.mouseMoveEvent(event)
@pyqtSlot(QMouseEvent, int, int)
def mouseRelease(self, event, x, y):
if (self.desLinha):
self.fim = self.view.mapToScene(QPoint(x,y))
self.linha.setLine(QLineF(self.inicio, self.fim))
QGraphicsView.mouseReleaseEvent(event)
To copy to clipboard, switch view to plain text mode
Bookmarks