def paint(
self,
painter: QtGui.QPainter,
opt: QtWidgets.QStyleOptionGraphicsItem,
w: QtWidgets.QWidget
):
"""
Reimplement the paint method of parent class.
This function is called by external QGraphicsView.
"""
rect = opt.exposedRect # exposedRect(暴露矩形)为什么有坐标值,我又没传坐标值给它。
min_ix = int(rect.left())
max_ix = int(rect.right())
max_ix = min(max_ix, len(self._bar_picutures))
rect_area = (min_ix, max_ix)
if rect_area != self._rect_area or not self._item_picuture:
self._rect_area = rect_area
self._draw_item_picture(min_ix, max_ix)
self._item_picuture.play(painter) # 这行代码又又什么作用?我直接用painter绘制就行,为什么还需要picture?
为什么要重写?paint()是什么时候被调用的?画图的函数明明是_draw_item_picture(),我只要在其他地方调用就可以画图了。为什么注册掉此方法,k线图都画不错来。
在百度上查找很久都未搞明白,所以只能在论坛中问。