【问题标题】:Qt QGraphicsView translate BackgroundBrushQt QGraphicsView 翻译 BackgroundBrush
【发布时间】:2015-12-25 07:03:27
【问题描述】:

我创建了一个从 QGraphicsView 派生的视图类,并将 backgroundBrush 设置为图像。我想翻译背景画笔。我已经尝试了以下

// graphicsView derived from QGraphicsView 
graphicsView->backgroundBrush().transform().translate(moveX, moveY);

但它并没有改变背景画笔。

【问题讨论】:

    标签: qt qgraphicsview


    【解决方案1】:

    backgroundBrush()transform() 被定义为 const 成员函数,这意味着它们不会修改调用它们的对象。

    你需要调用setBackgroundBrush()setTransform()来修改这些属性:

    QBrush brush = graphicsView->backgroundBrush();
    brush.setTransform(QTransform::fromTranslate(moveX, moveY));
    graphicsView->setBackgroundBrush(brush);
    

    【讨论】:

      猜你喜欢
      • 2018-05-13
      • 1970-01-01
      • 1970-01-01
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多