나는 여러 개의 QDoubleSpinBox를 가지고 있으며, 하나의 슬롯에 연결하려고합니다. 둘 이상의 객체에 대해 하나의 연결 명령을 만들 수 있습니까?하나의 연결 명령으로 여러 개의 스핀 상자를 연결하는 방법은 무엇입니까?
doubleSpinBox_1
doubleSpinBox_2
내 기능 "즐"에 : exampe, 나는 연결하려는. 다음과 같은 명령이 있습니까 :
?
나는 여러 개의 QDoubleSpinBox를 가지고 있으며, 하나의 슬롯에 연결하려고합니다. 둘 이상의 객체에 대해 하나의 연결 명령을 만들 수 있습니까?하나의 연결 명령으로 여러 개의 스핀 상자를 연결하는 방법은 무엇입니까?
doubleSpinBox_1
doubleSpinBox_2
내 기능 "즐"에 : exampe, 나는 연결하려는. 다음과 같은 명령이 있습니까 :
?
이 시도 :
for spin_id in range(1,3):
spinboxes = self.findChildren(QtGui.QDoubleSpinBox, "doubleSpinBox_%d"%spin_id)
if spinboxes:
spinboxes[0].valueChanged.connect(self.bla)
을하지만,이 코드는 당신이 많은 연결 spinboxes있는 경우에 유용하다) 또는
을, 당신은 사용할 수 getattr
:
for id in range(1,3):
spinbox = getattr(self, "doubleSpinBox_{}".format(id))
spinbox.valueChanged.connect(self.mySlot)