| 53 | |
| 54 | |
| 55 | class ToolTipWidget(QWidget): |
| 56 | Cache = {} |
| 57 | |
| 58 | def __init__(self, *args, **kwargs): |
| 59 | super(ToolTipWidget, self).__init__(*args, **kwargs) |
| 60 | self.setAttribute(Qt.WA_StyledBackground, True) |
| 61 | self.setStyleSheet( |
| 62 | "ToolTipWidget{background: rgba(50, 50, 50, 100);}") |
| 63 | layout = QVBoxLayout(self) |
| 64 | self.titleLabel = QLabel(self, styleSheet="color:white;") |
| 65 | layout.addWidget(self.titleLabel) |
| 66 | |
| 67 | def updateUi(self, title, points): |
| 68 | self.titleLabel.setText(title) |
| 69 | for serie, point in points: |
| 70 | if serie not in self.Cache: |
| 71 | item = ToolTipItem( |
| 72 | serie.color(), |
| 73 | (serie.name() or "-") + ":" + str(point.y()), self) |
| 74 | self.layout().addWidget(item) |
| 75 | self.Cache[serie] = item |
| 76 | else: |
| 77 | self.Cache[serie].setText( |
| 78 | (serie.name() or "-") + ":" + str(point.y())) |
| 79 | self.Cache[serie].setVisible(serie.isVisible()) # 隐藏那些不可用的项 |
| 80 | self.adjustSize() # 调整大小 |
| 81 | |
| 82 | |
| 83 | class GraphicsProxyWidget(QGraphicsProxyWidget): |