如何基于QcomboBox索引切换小部件的启用状态

2024-09-24 10:25:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用pyQT 4.8.3为QGIS插件创建一个合适的GUI

表单中有三个小部件

my_comboBox , my_lineEdit , my_spinBox

假设组合框有三个条目

'combo_first_item' , 'combo_second_item' , 'combo_third_item'

我真正想要的是

if 'combo_second_item' is selected, then my_lineEdit toggles state to disabled
if 'combo_third_item' selected, then my_spinBox toggles state to disabled

那么,如何根据组合框中选定的字符串(或索引值)在表单中切换小部件的启用状态?

什么应该是正确的信号->;插槽分配? 与QbuttonBox不同,QcomboBox不启动SetDisabled插槽

谢谢。


Tags: to表单if部件myitemstateselected