[PyQt] signal-slot connect problem

David Douard david.douard at logilab.fr
Wed Jan 9 08:15:07 GMT 2008


On Tue, Jan 08, 2008 at 05:26:53PM +0000, Phil Thompson wrote:
> On Tuesday 08 January 2008, Martin Höfling wrote:
> > Hi all,
> >
> > I am trying to create a filter Toolbar bar class, filtering a model.
> >
> > why does the following connect command  in the loadModel Method not work?:
> >
> > class FilterToolBar(QToolBar):
> >     def __init__(self):
> >         super(FilterToolBar,self).__init__(QString("Filter"))
> >         self.expFilterCombo=QComboBox()
> >         self.projFilterCombo=QComboBox()
> >         self.expFilterCombo.setVisible(True)
> >         self.projFilterCombo.setVisible(True)
> >         self.addWidget(self.expFilterCombo)
> >         self.addWidget(self.projFilterCombo)
> >         self.expFilterCombo.setEditable(True)
> >         self.projFilterCombo.setEditable(True)
> >
> >     def loadModel(self,  proxymdl1,  proxymdl2, model):
> >         self.proxymdlexp=proxymdl1
> >         self.proxymdlproj=proxymdl2
> >         self.expFilterCombo.clear()
> >         self.projFilterCombo.clear()
> >         self.expFilterCombo.clearEditText()
> >         self.projFilterCombo.clearEditText()
> >         exps=model.experiments.keys()
> >         projs=model.projects.keys()
> >         addToComboBox(exps, self.expFilterCombo)
> >         addToComboBox(projs, self.projFilterCombo)
> >
> > #problem section start
> >         self.connect(self.expFilterCombo, SIGNAL("editTextChanged()"),
> > self.expFilterChanged)
> >         self.connect(self.projFilterCombo, SIGNAL("editTextChanged()"),
> > self.projFilterChanged)
> > #problem section stop
> >
> >     def expFilterChanged(self):
> >        print "Filter Exp update"
> >       
> > self.proxymdlexp.setFilterFixedString(self.expFilterCombo.itemText())
> > self.proxymdlexp.setFilterKeyColumn(EXPERIMENT)
> >
> >     def projFilterChanged(self):
> >        print "Filter Proj update"
> >       
> > self.proxymdlproj.setFilterFixedString(self.projFilterCombo.itemText())
> > self.proxymdlproj.setFilterKeyColumn(PROJECT)
> >
> > The filter toolbar is created on startup and the loadModel Method is called
> > when a new model has been loaded. Nothing happens if i change the text.
> 
> Because there is no signal with that signature - you've missed out the 
> argument type.

This makes me think: would'nt be possible to display a warning message
(or to add a flag somewhere which would activate this feature) when
pyqt detects a wrong signature in SIGNAL ?

I know this would break (so the idea of the flag) the easy way of
SIGNAL/SLOT in pure python (as a -- positive in my mind -- side
effect, people would be more incitated to use the pyQtSignature in
python code).

I mean it is a very common mistake, even for advanced PyQt developers,
and it is not always easy to track. It could at least save sometimes
one hour or two to many PyQt developpers, I guess ;-)
 
> 
> Phil
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 

-- 
David Douard                        LOGILAB, Paris (France), +33 1 45 32 03 12
Formations Python, Zope, Debian :   http://www.logilab.fr/formations
Développement logiciel sur mesure : http://www.logilab.fr/services
Informatique scientifique :         http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080109/2f87e5de/attachment.bin


More information about the PyQt mailing list