本文整理汇总了Python中AnyQt.QtCore.QObject.property方法的典型用法代码示例。如果您正苦于以下问题:Python QObject.property方法的具体用法?Python QObject.property怎么用?Python QObject.property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QObject
的用法示例。
在下文中一共展示了QObject.property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_manager
# 需要导入模块: from AnyQt.QtCore import QObject [as 别名]
# 或者: from AnyQt.QtCore.QObject import property [as 别名]
def test_manager(self):
source = QObject()
target = QObject()
manager = BindingManager(submitPolicy=BindingManager.ManualSubmit)
manager.bind((target, "target"), None).to((source, "source"))
tbind = DynamicPropertyBinding(target, "target_copy")
sbind = DynamicPropertyBinding(source, "source")
schanged = []
sbind.changed[object].connect(schanged.append)
manager.bind(tbind, None).to(sbind)
source.setProperty("source", 1)
self.assertEqual(len(schanged), 1)
self.assertEqual(target.property("target"), None)
manager.commit()
self.assertEqual(target.property("target"), 1)
self.assertEqual(target.property("target_copy"), 1)
source.setProperty("source", 2)
manager.setSubmitPolicy(BindingManager.AutoSubmit)
self.assertEqual(target.property("target"), 2)
self.assertEqual(target.property("target_copy"), 2)
示例2: test_dyn
# 需要导入模块: from AnyQt.QtCore import QObject [as 别名]
# 或者: from AnyQt.QtCore.QObject import property [as 别名]
def test_dyn(self):
obj = QObject()
changed = []
binding = DynamicPropertyBinding(obj, "test")
binding.changed[object].connect(changed.append)
self.assertIs(binding.get(), None)
obj.setProperty("test", 1)
self.assertEqual(binding.get(), 1)
self.assertEqual(len(changed), 1)
self.assertEqual(changed[-1], 1)
binding.set(2)
self.assertEqual(binding.get(), 2)
self.assertEqual(len(changed), 2)
self.assertEqual(changed[-1], 2)
target = QObject()
binding1 = DynamicPropertyBinding(target, "prop")
binding1.bindTo(binding)
self.assertEqual(binding1.get(), binding.get())
self.assertEqual(target.property("prop"), 2)
binding.set("a string")
self.assertEqual(binding1.get(), "a string")
self.assertEqual(binding1.get(), binding.get())
self.assertEqual(target.property("prop"), "a string")
binding1.unbind()
binding.set(1)
self.assertEqual(binding1.get(), "a string")
self.assertEqual(target.property("prop"), "a string")
self.assertEqual(binding.get(), 1)
self.assertEqual(obj.property("test"), 1)