【问题标题】:How to detect a QGraphicsItem moving performing by mouse?如何检测由鼠标执行的 QGraphicsItem 移动?
【发布时间】:2013-10-29 23:35:38
【问题描述】:

我有一个带有 Selectable 和 Movable 标志的 QGraphicsItem 子类。当我选择许多项目并移动它们时,所有项目都会收到 itemChange 事件。有没有办法在 itemChanged 中检测到鼠标按钮仍然被按下?

【问题讨论】:

    标签: qt qgraphicsitem


    【解决方案1】:

    请参考QApplication::mouseButtons()function,它将返回鼠标按钮的当前状态Qt::MouseButtons

    Qt::MouseButtons btns = QApplication::mouseButtons();
    if (btns & Qt::LeftButton) {
        // The left button is pressed.
        [..]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      • 2018-12-10
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多