我的工作环境:Qt 5.8 MSVC2015 64bit, QT GraphicsView, Windows 7 64 bit
当 GraphicsView 垂直滚动条消失时,缩小应该停止。
所以我尝试了下面的代码,但它失败了:
void GraphicsView::scale(qreal scaleFactor)
{
QRectF r(0, 0, 1, 1); // A reference
int pos_x = this->horizontalScrollBar()->value();
int pos_y = this->verticalScrollBar()->value();
qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(r).width(); // absolute zoom factor
if ( factor > 7) { // Check zoom out limit
return;
}
//Failed, this code failed If zoom out again.**
if(pos_x <= 0 && pos_y <= 0 )
{
return;
}
任何建议我该怎么做才能修复上述代码?