QML&C++应用程序中的绑定循环问题
Binding loop problem in an application with QML&C++
我正在进行一个项目,基本上我想做的是在2个QML文件中的2个盒子之间同步属性 theProperty
(两个都有该属性(,我将 theProperty
绑定到一个c q_property,因此,通过将2个框结合到相同的C Q_property,可以实现同步。这是我的Box A和B中的代码。theProperty
可以通过Box A和B
Box_A {
id: box_A
// sth
Binding { target:box_A; property: "theProperty"; value:model.CppModel.theProperty }
onThePropertyChanged: {
model.CppModel.theProperty = theProperty
}
}
Box_B {
id: box_B
// sth
Binding { target:box_B; property: "theProperty"; value:model.CppModel.theProperty }
onThePropertyChanged: {
model.CppModel.theProperty = theProperty
}
}
在CPP中:
Class Item: QObject{
Q_OBJECT
Q_PROPERTY(bool theProperty READ theProperty WRITE theProperty NOTIFY theProperty Changed)
//sth
}
在Box_a和B中,有一个可以更改theProperty
的鼠标区域:
MouseArea{
onClicked: theProperty=!theProperty
}
问题是,一旦我在盒子A或B中更改theProperty
,QT创建者抱怨循环绑定以绑定为值:model.CppModel.theProperty
在另一侧,是否有一种方法可以在此问题上行走?
为什么不这样做:
Box_A {
id: box_A
// sth
theProperty:model.CppModel.theProperty
}
那对您不起作用吗?
相关文章:
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 在基于范围的for循环中使用结构化绑定声明
- 使用 LuaBridge 将 LuaJIT 绑定到C++会导致"PANIC: unprotected error"
- 尝试通过OCI例程从Oracle获取blob数据,但出现错误:ORA-01008:并非所有变量都绑定
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- 视觉studo 2019中的漫画和静态/动态绑定
- 将自由函数绑定为类成员函数
- 将常量指针引用绑定到非常量指针
- 在派生类中绑定非静态模板化成员函数
- 绑定派生类方法C++从实例范围之外的分隔 std::function 变量调用
- 在 openGL 中多次绑定缓冲区
- 定义有趣的宏和正则表达式在Z3 C++绑定
- 使用结构化绑定'Reflection'
- 为什么 std::绑定错误参数可以成功?
- 为什么基于范围的 for 循环中的结构化绑定只是一个副本而不是引用?
- QML 检测到属性宽度的绑定循环(TextMetrics 行为很奇怪)
- QML&C++应用程序中的绑定循环问题
- 顶级qml文件中的Repeater元素导致QtQuick 1.1(QtCreator 3.5.1)中的绑定循环
- 在Java绑定中循环使用OpenCV Mat
- Windows 8 APP,用数据绑定改变XAML文本框的文本.游戏循环工作线程导致问题