[PyQt] headerDataChanged connection: new-style syntax problem

Vicent Mas uvemas at gmail.com
Sat Nov 13 12:17:35 GMT 2010


On 2010-11-13 Phil Thompson <phil at riverbankcomputing.com> said:

> On Sat, 13 Nov 2010 11:08:20 +0100, Vicent Mas <uvemas at gmail.com> wrote:
> > On 2010-11-13 Phil Thompson <phil at riverbankcomputing.com> said:
> >> On Sat, 13 Nov 2010 09:57:26 +0100, Vicent Mas <uvemas at gmail.com>
> 
> wrote:
> >> > Hi,
> >> > 
> >> > I'm upgrading some code and moving signal/slot connections from old
> >> 
> >> style
> >> 
> >> > to
> >> > 
> >> > new style but I'm having problem with this line:
> >> >         self.connect(self.tmodel,
> 
> QtCore.SIGNAL("headerDataChanged(int,
> 
> >> >         int,
> >> > 
> >> > int)"), self.my_slot)
> >> > 
> >> > where self is an instance of QtGui.QTableView and self.tmodel is an
> >> > instance
> >> > of QtCore.QAbstractTableModel.
> >> > 
> >> > I've tried:
> >> > 
> >> > 1) self.tmodel.headerDataChanged.connect(self.my_slot)
> >> > 2) self.tmodel.headerDataChanged[int, int, int].connect(self.my_slot)
> >> > 
> >> > and other variations with no luck. Could someone tell me how to
> 
> convert
> 
> >> it
> >> 
> >> > to
> >> > the new-style syntax, please? I'm using Qt-4.6.3 and PyQt-4.8.
> >> 
> >> Define "no luck".
> >> 
> >> Phil
> >> 
> > :-) I mean that some times my program aborts, other times I get no
> 
> errors
> 
> > but
> > the slot is never executed. I don't use any debugger, I just put a print
> > 
> > 'something' in the first line of the slot but the string is never
> 
> printed.
> 
> > The
> > old-style version works just fine.
> 
> So you need to create a test that demonstrates the problem.
> 
> Phil

Hi,

finally I caught on the problem. I was considering the connection part but I 
forgot about the emission part. The model was explicitly emitting the 
headerDataChanged signal using the old-style syntax. So when I tried to 
connect the emitted signal to a slot using the new-style syntax I was mixing 
both styles when dealing with that signal. Not a good idea. Emitting the 
signal with the new-style syntax solves the problem.

Sorry for the noise,

Vicent
::

	Share what you know, learn what you don't

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101113/f0df3bba/attachment.pgp>


More information about the PyQt mailing list