On Saturday 05 March 2011, 21:20:49 Entity Reborn wrote:
> For some reason, with this code, I cannot get newitemfunc called.
>
> >  from PyQt4 import QtCore, QtGui
> >
> > import sys
> >
> >> def newitemfunc(parentitem, newitem):
> >
> >     print("newitem")
> >
> >> class class1(QtCore.QObject):
> >
> >     pass
> >
> >> class class2(QtCore.QAbstractItemModel):
> >
> >     def test1(self, data):
> >
> >         return self.test2(data, class1())
> >
> >>     def test2(self, data, curitem):
> >
> >         if "SubItems" in data:
> >
> >             for item in data["SubItems"]:
> >
> >                 newitem = class1()
> >
> >                 print("emitting")
> >
> >                 newitem.emit(QtCore.SIGNAL("newitem"), newitem)

You're emitting the signal from a different class to what you connected 
from. You really should use new style signals/slots to get better 
feedback for failures..

> >                 self.test2(item, newitem)
> >
> >> class MainWindow(QtGui.QMainWindow):
> >
> >     def __init__(self, data, *args):
> >
> >         super(MainWindow, self).__init__(*args)
> >
> >         self.model = class2()
> >
> >         print("connecting")
> >
> >         self.connect(self.model, QtCore.SIGNAL("newitem"),
> > newitemfunc)

        self.model is class2

> >
> >         self.model.test1(data)
> >

Hth,
Pete
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to