【问题标题】:repeating Rectangle by clicking mouse in QT QML通过在QT QML中单击鼠标重复矩形
【发布时间】:2012-07-25 09:23:43
【问题描述】:

鼠标onReleased好像不能使用repeat!?我该怎么做?我想在一些已经定义的矩形边缘上显示 4 个圆圈?

onReleased:{
    Repeater {
    id: repeatEdirPattern
    model: editParentPositionList
    delegate: editPatternComponent
    }
}

【问题讨论】:

    标签: c++ qt sdk qt4 qml


    【解决方案1】:

    MouseArea.onReleased 接受 JS 函数的定义(发出 MouseArea.released SIGNAL 时要调用的 SLOT)。您不能在其中放入任意 QML 声明性定义。

    要做你需要的,你必须在一个Component项目中定义你的Repeater,然后当鼠标被释放时创建那个组件,调用Component.createObject方法。

    另一种简单的方法是简单地隐藏 4 个圆圈(将它们的不透明度设置为 0),直到释放鼠标,然后将它们显示出来。无论如何,这不适合很多情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-12
      • 2017-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-08
      相关资源
      最近更新 更多