1

次のコードがあります。

#####   Slots for checkboxes (enable/disabling)
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.checkBox_3.setOn)
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.dateEdit.setEnabled)
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.dateEdit_2.setEnabled)
QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.lineEdit.setEnabled)
QtCore.QObject.connect(self.checkBox_2, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.lineEdit_2.setEnabled)
QtCore.QObject.connect(self.checkBox_4, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), self.lineEdit_3.setEnabled)
#####

##### Slots for checkboxes/lineEdits (filling dict for database fields and values)
QtCore.QObject.connect(self.checkBox, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), lambda: self.interfaceCodesConstructor.setFilterDict(self,"name",self.lineEdit.text()))
QtCore.QObject.connect(self.checkBox_2, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), lambda: self.interfaceCodesConstructor.setFilterDict(self,"bought_price",persianToInteger(unicode(self.lineEdit_2.text()))))
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), lambda: self.interfaceCodesConstructor.setFilterDict(self,"bought_date",self.dateEdit.text())) ##date        
QtCore.QObject.connect(self.checkBox_4, QtCore.SIGNAL(_fromUtf8("stateChanged(int)")), lambda: self.interfaceCodesConstructor.setFilterDict(self,"stock",persianToInteger(unicode(self.lineEdit_3.text()))))        


QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))
QtCore.QObject.connect(self.lineEdit_2, QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))
QtCore.QObject.connect(self.dateEdit, QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))         
QtCore.QObject.connect(self.lineEdit_3, QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))        



#### pressing seach key and start search action
QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8("returnPressed()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))
QtCore.QObject.connect(self.pushButtonSearch, QtCore.SIGNAL(_fromUtf8("clicked()")), lambda: self.interfaceCodesConstructor.responseToRequestForData(self))
#######



##    enable/disabling "price date" checkbox
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.dateEdit.setEnabled)
QtCore.QObject.connect(self.checkBox_3, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.dateEdit_2.setEnabled)

次にSLOT、別のファイルに次のものがあります。

def setFilterDict(self,obj,field,lineEditContent):
    self.objectSearchMaterials = obj

    if field not in self.filterNameDict.keys():# and self.filterNameDict.values() is not None:
        self.filterNameDict.update({field:lineEditContent})
    else:
        del self.filterNameDict[field] 

私の質問は、 をクリックすると、辞書checkboxesにテキストを入力します: self.filterNameDict、しかし、複数回クリックすると、指定された辞書を処理できません。ハンドルごとに動的に辞書を作成する方法はcheckboxes? checkboxそれは、フィールドの名前を追加して口述するときにクリックする必要があることを意味し、lineEdit text()それを削除すると、口述から自動的に削除されますか?

4

1 に答える 1