【问题标题】:List of checked boxes in Pyside?Pyside中的复选框列表?
【发布时间】:2012-07-13 14:49:48
【问题描述】:

我在 qtdesigner 中创建了一个带有许多复选框的 gui: Screenshot http://imgq.tk/img/-2012-07-13%2013:55:07.png

我想知道是否有一种方法可以使用 pyside 列出所有选中的框。如果我能从每个框中获取文本会更好。这些框采用网格布局。

【问题讨论】:

    标签: python qt checkbox pyside qt-designer


    【解决方案1】:

    既然你在 python 中,你应该能够内省对象并找到它的所有成员。但是由于父子关系,Qt 通常使这很容易。您可以在表单(父级)中查询其作为文本框的子级:

    # my python's a bit rusty, but hopefully this is close
    checkboxes = [x for x in form.children() where isinstance(x, QCheckBox)]
    

    查看findChildren()children() 方法。

    【讨论】:

    猜你喜欢
    • 2017-11-16
    • 1970-01-01
    • 2013-10-25
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    相关资源
    最近更新 更多