-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiagramtextitem.py
42 lines (26 loc) · 1.12 KB
/
diagramtextitem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsTextItem, QGraphicsItem, QGraphicsLineItem
from PyQt5.QtCore import QObject, Qt, pyqtSignal, QLineF
class DiagramTextItem(QGraphicsTextItem):
Type = 3
lostFocus = pyqtSignal(QObject)
selectedChange = pyqtSignal(QGraphicsItem)
def __init__(self, parent=None):
super().__init__(parent)
self.setFlag(QGraphicsItem.ItemIsMovable, True)
self.setFlag(QGraphicsItem.ItemIsSelectable, True)
# def type(self):
# return self.Type
def itemChange(self, change, value):
if (change == QGraphicsItem.ItemSelectedHasChanged):
self.selectedChange.emit(self)
return value
def focusOutEvent(self, event):
print('test2')
self.setTextInteractionFlags(Qt.NoTextInteraction)
self.lostFocus.emit(self)
super().focusOutEvent(event)
def mouseDoubleClickEvent(self, event):
print('test3')
if (self.textInteractionFlags() == Qt.NoTextInteraction):
self.setTextInteractionFlags(Qt.TextEditorInteraction)
super().mouseDoubleClickEvent(event)