【问题标题】:How to reset the scale in QGraphicsView?如何在 QGraphicsView 中重置比例?
【发布时间】:2016-08-23 12:55:02
【问题描述】:

如何重置图形视图的比例,而不考虑之前应用的任何比例?使用scale() 将我给它的比例乘以前一个:

ui->graphicsView->scale(0.1, 0.1);
ui->graphicsView->scale(2, 2);
// the scale factor is (0.2,0.2) instead of (2,2)

【问题讨论】:

    标签: c++ qt qgraphicsview


    【解决方案1】:

    QGraphicsView::resetMatrix() 重置矩阵,并在应用比例之前调用它:

    view->scale(0.1, 0.1);
    view->resetMatrix();
    view->scale(2, 2);
    // the scale factor is (2,2)
    

    【讨论】:

      【解决方案2】:

      补充一点:

      QGraphicsView::resetMatrix()等于QGraphicsView::resetTransform(),从源码可以看出:

      void QGraphicsView::resetMatrix()
      {
          resetTransform();
      }
      

      【讨论】:

      • 是的,现在你必须使用 resetTransform(),因为 resetMatrix() 已被弃用。
      猜你喜欢
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 2010-10-25
      • 2016-02-15
      相关资源
      最近更新 更多