pyqtgragh ROI

classpyqtgraph.ROI(pos, size=Point(1.0, 1.0), angle=0.0, invertible=False, maxBounds=None, snapSize=1.0, scaleSnap=False, translateSnap=False, rotateSnap=False, parent=None, pen=None, hoverPen=None, handlePen=None, handleHoverPen=None, movable=True, rotatable=True, resizable=True, removable=False, aspectLocked=False)

参数:
maxBounds
:(QRect、QRectF 或 None)指定用户不能将 ROI 拖到外部的边界。 默认为无。
这个参数非常让人迷惑,我定义了

roi = pg.RectROI([1, 1], [27, 28], maxBounds=QRect(0, 0, 100, 100))

绑定sigRegionChanged后,一直报错:
TypeError: arguments did not match any overloaded call:
| contains(self, QPoint, proper: bool = False): argument 1 has unexpected type ‘QRectF’
| contains(self, QRect, proper: bool = False): argument 1 has unexpected type ‘QRectF’
| contains(self, int, int, bool): argument 1 has unexpected type ‘QRectF’
| contains(self, int, int): argument 1 has unexpected type 'QRectF

最后发现,应该改为:

roi = pg.RectROI([1, 1], [27, 28], maxBounds=QRectF(0, 0, 100, 100))

这个错误提示非常具有迷惑性。。。

上一篇:vue - public 引入