重绘时会出现上一刻的部分轨迹
原因:输入矩形非法,如通过鼠标事件获取两点,其顺序是随机的,可能导致矩形的宽或者高为负数
void setRect(const QRectF &rectangle)
文档有解释:
Note: The rendering of invalid rectangles, such as those with negative widths or heights, is undefined. If you cannot be sure that you are using valid rectangles (for example, if you are creating rectangles using data from an unreliable source) then you should use QRectF::normalized() to create normalized rectangles, and use those instead.
可以通过QRectF::normalized() 来获得left<right,top<bottom的矩形