嗨,我对PySide2还是比较新的,在maya中设置了一些UI。 有没有可能有一个QPushButton,它有其他小部件作为子部件?你知道吗
例如,我想制作一对并排的QPushButtona,当其中一个被单击时,它们可以打开或关闭,每一个都应该有一个spinBox。如果spinBox的父按钮为“off”,则该spinBox将被禁用
我本来打算做一个简单的button类,可以关闭它的对应项,所以这一点很简单,但是我看不到一个方法可以把spinBox也放进去,也许我错过了什么?我能给我的按钮添加一个布局然后在里面添加小部件吗?你知道吗
谢谢你的帮助
本
实际上,您可以使用
QGroupBox
,因为您已经可以使其可检查并在其中添加项。当选中groupbox的复选框时,它将禁用其任何内容。所以大部分框架已经存在了。唯一的问题不是复选框,而是希望它像QRadioButton
一样工作,以便其他复选框禁用。我们可以用一些简单的逻辑来处理:想知道这是否可能,看起来是的,您可以使用一个按钮并在其中嵌套另一个小部件。我原以为你得多跳几圈才能让它正常工作,但也不算太糟。你知道吗
您可以使按钮可检查,然后使用
QButtonGroup
使按钮的行为类似于QRadioButton
。尽管与QGroupBox
不同,您需要自己处理数字调整框的启用状态。下面是一个有效的例子:从技术上讲,不需要对
QPushButton
进行子类化,尽管这样可以更容易地回收代码。你知道吗相关问题 更多 >
编程相关推荐