Traceback (most recent call last): File "F:\conda\envs\yolov5\lib\site-packages\libs\canvas.py", line 526, in paintEvent p.drawRect(left_top.x(), left_top.y(), rect_width, rect_height) TypeError: arguments did not match any overloaded call: drawRect(self, rect: QRectF): argument 1 has unexpected type 'float' drawRect(self, x: int, y: int, w: int, h: int): argument 1 has unexpected type 'float' drawRect(self, r: QRect): argument 1 has unexpected type 'float'
时间: 2024-04-01 12:38:02 浏览: 104
rich-traceback:Python 日志记录模块的信息回溯
这个错误是由于 `drawRect` 方法中的参数类型不匹配。该方法要求的参数类型应该是整数或者 `QRect` 对象,而传入的参数类型是浮点数,导致了类型不匹配的错误。解决方法是将传入参数的类型强制转换为整型或者 `QRect` 对象。例如,可以将 `p.drawRect(left_top.x(), left_top.y(), rect_width, rect_height)` 改为 `p.drawRect(int(left_top.x()), int(left_top.y()), int(rect_width), int(rect_height))`。
阅读全文