[英]What is the best way to connect between python dict and PyQt widget?
I have a giant dict with thousands of keys, and some of that keys also are giant dicts, and so on. 我有一个包含数千个键的巨型字典,其中一些键也是巨型字典,依此类推。
Also I have a lot of widgets with their fields. 我也有很多与他们的领域的小部件。
What I need is to show some preferred (by me) values from dict at my widgets. 我需要的是在我的窗口小部件上显示dict的一些(首选)值。 But not only show: when value is edited in one place (either widget or dict), I need to automatically change it at the second place.
但不仅要显示:在一个位置(小部件或字典)编辑值时,我需要在第二个位置自动更改它。
The point is, I need to do it real simple and auto, because there are too many values and too many fields. 关键是,我需要真正简单而自动地执行此操作,因为值太多,字段太多。
ps Someone who understand my post, please, suggest fixes correcting my grammar. ps请了解我的帖子的人提出修正我的语法的建议。 I'm sorry for that.
对此我感到抱歉。 Thank you.
谢谢。
You could derive your own model based on QAbstractItemModel , that gives an interface to your dict, without needing to copy values. 您可以基于QAbstractItemModel派生自己的模型,该模型为dict提供接口,而无需复制值。 Then you could display your values using either something derived from QTreeView or QColumnView .
然后,您可以使用从QTreeView或QColumnView派生的值显示值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.