QRect(int x,int y,int width,int height)允许负值?
一个矩形,正值是合理的,负值是错误的。QRect支持负值,有时绘画出来,是个反家伙。
用unsigned int是不是更合理一些?
void setScaleType(){ //这里需要重新计算,并将图框重新设置一下 if ((scaleType!=m_eumScaleType) && (SCALE_FIX==scaleType)) { QRect rectAdjust = m_rectOfRedLine; int newWidth = rectAdjust.width(); int newHeight = newWidth * CAPTURE_HEIGHT / CAPTURE_WIDTH; int newHeight2 = rectAdjust.height(); int newWidth2 = newHeight2 * CAPTURE_WIDTH / CAPTURE_HEIGHT; if (newWidth > newWidth2) { rectAdjust.setRight(rectAdjust.left() + newWidth2); rectAdjust.setBottom(rectAdjust.top() + newHeight2); } else { rectAdjust.setRight(rectAdjust.left() + newWidth); rectAdjust.setBottom(rectAdjust.top() + newHeight); } if (m_rcPixmapTarget.contains(rectAdjust) && (rectAdjust.width()>10) //最小尺寸 && (rectAdjust.height()>10) //最小尺寸 ) { //没有越界 m_rectOfRedLine = rectAdjust; calculateMiniRect(); capturePixmap(); //截取 repaint(); } } m_eumScaleType = scaleType;}