[PyQt] Qt connect and first connect or unicode

Mohsen Pahlevanzadeh mohsen at pahlevanzadeh.org
Tue Sep 17 05:37:08 BST 2013


Dear all,

Unfortunately, i confused and need help... the following code is:
###################################################
##CheckBox:
    QtCore.QObject.connect(self.checkBox,
QtCore.SIGNAL(_fromUtf8("toggled(bool)")), lambda:
self.materialsInstance.setFilterDict("C",self,"name",self.lineEdit.text()))

        QtCore.QObject.connect(self.checkBox_2,
QtCore.SIGNAL(_fromUtf8("toggled(bool)")), lambda:
self.materialsInstance.setFilterDict("C",self,"bought_price",persianToInteger(unicode(self.lineEdit_2.text()))))

        QtCore.QObject.connect(self.checkBox_4,
QtCore.SIGNAL(_fromUtf8("toggled(bool)")), lambda:
self.materialsInstance.setFilterDict("C",self,"stock",persianToInteger(unicode(self.lineEdit_3.text()))))

##LineEdit
        QtCore.QObject.connect(self.lineEdit,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.setFilterDict("L",self,"name",self.lineEdit.text()))

        QtCore.QObject.connect(self.lineEdit_2,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.setFilterDict("L",self,"bought_price",persianToInteger(unicode(self.lineEdit_2.text()))))

        QtCore.QObject.connect(self.lineEdit_3,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.setFilterDict("L",self,"stock",persianToInteger(unicode(self.lineEdit_3.text()))))        

        QtCore.QObject.connect(self.lineEdit,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.responseToRequestForData(self))

        QtCore.QObject.connect(self.lineEdit_2,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.responseToRequestForData(self))

        QtCore.QObject.connect(self.lineEdit_3,
QtCore.SIGNAL(_fromUtf8("editingFinished()")), lambda:
self.materialsInstance.responseToRequestForData(self))        

        QtCore.QObject.connect(self.lineEdit,
QtCore.SIGNAL(_fromUtf8("returnPressed()")), lambda:
self.materialsInstance.responseToRequestForData(self))

        QtCore.QObject.connect(self.lineEdit_2,
QtCore.SIGNAL(_fromUtf8("returnPressed()")), lambda:
self.materialsInstance.responseToRequestForData(self))

        QtCore.QObject.connect(self.lineEdit_3,
QtCore.SIGNAL(_fromUtf8("returnPressed()")), lambda:
self.materialsInstance.responseToRequestForData(self))        

##PushButton:
        QtCore.QObject.connect(self.pushButtonSearch,
QtCore.SIGNAL(_fromUtf8("clicked()")), lambda:
self.materialsInstance.responseToRequestForData(self))



    def setFilterDict(self,widget,obj,field,lineEditContent):
        if field not in obj.materialsInstance.filterNameDict.keys():

obj.materialsInstance.filterNameDict.update({field:lineEditContent})


####################################################
Description:
I have 3 widget:
1. CheckBox:  a. name b. bought_price c. stock
2. LineEdit : a. name b. bought_price c. stock
3. One PushButton

i have three slot: 1. responseToRequestForData()  2.setFilterDict()
3.unSetFilterDict()
responseToRequestForData(): start to search in DB
setFilterDict(): fill a dict from my LineEdit

Problem:
My name is filled in dict but its value doesn't fill up. b and c don't
have any problem.

I get the following output in console:
{'stock': 2, 'name': PyQt4.QtCore.QString(u''), 'bought_price': 23}

Yours,
Mohsen




More information about the PyQt mailing list