[PyKDE] Problems (bug?) in 3.2.2

Andreas Gerstlauer gerstl at ics.uci.edu
Mon May 13 09:28:00 BST 2002


Hi!

I installed the bugifx release 3.2.2 of sip and PyQt today
(working with Qt 3.0.4 and Python 2.2.1).
First of all, thanks, the thread-related bug in emit() for 
Qt signals is gone.

However, I am having new problems with this release. Attached
is a little test script that produces the bug. The script
runs fine with 3.2.1 but produces the following with 3.2.2:

% python test.py
Printing names...
Traceback (most recent call last):
File "test.py", line 50, in ?
  w.printNames()
File "test.py", line 41, in printNames
  child.printNames()
AttributeError: printNames

It looks like the C++ pointers returned by calls to Qt 
methods are not properly converted back into their
corresponding wrapped objects. Instead of finding the
derived and overloaded object the calls return a plain,
virgin object, i.e. all the custom members are not
there.
Like I said, this used to work before (and is, AFAIK,
a feature of sip/PyQt - otherwise I would have to do
some sort of "casting" back) so I would assume it is
a bug?! Or is this an intentional change? In the latter
case, how can I program my old behavior back...?

Another problem I am having is that I have a QPopupMenu
for which I connect the signal "aboutToShow()" to a slot
of mine (to fill the menu on demand with dynamic content)
but that slot suddenly doesn't get called anymore when
I open the menu. I haven't had a chance to investigate 
further but the code fragment looks something like this:

class FileMenu(QPopupMenu):
    def __init__(self, parent, actions):
        QPopupMenu.__init__(self, parent, "File Menu")
			            
        self.recentFilesMenu = QPopupMenu(self)
        self.connect(self.recentFilesMenu, SIGNAL('aboutToShow()'),
		                     self.setupRecentFilesMenu)
        self.insertItem("&Recent Files", self.recentFilesMenu)

    def setupRecentFilesMenu(self):
        print "Never gets called!!"
	self.recentFilesMenu.clear()
	for i in range(len(recentFiles)):
	    self.recentFilesMenu.insertItem(recentFile[i], i)

Again, this worked fine with everything before and including 3.2.1
but not any more with 3.2.2. The setupRecentFilesMenu() method 
doesn't get called any more when I open the menu - no error messages,
nothing. I don't know if  it's related to the above problem or not...?!

Andreas
-------------- next part --------------
#! python
    
import sys
from qt import *
    

class MyListViewItem(QListViewItem):
    
    def __init__(self, parent, leaf = 0):
        QListViewItem.__init__(self, parent)
        
        # set variables
        self.name = "MyItem"
        
        # add a child
        if not leaf:
            child = MyListViewItem(self, 1)

    def printNames(self):
        """Hierarchically descend tree and call printNames()."""
        print self.name
        child = self.firstChild()
        while child:
            child.printNames()
            child = child.nextSibling()
    
        
class MyListView(QListView):
    
    def __init__(self, parent = None):
        QListView.__init__(self, parent)
        
        # add child
        child = MyListViewItem(self)
        
    def printNames(self):
        """Hierarchically descend tree and call printNames()."""
        print "Printing names..."
        child = self.firstChild()
        while child:
            child.printNames()
            child = child.nextSibling()

        
if __name__ == "__main__":
    a = QApplication(sys.argv)
    a.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    w = MyListView()
    a.setMainWidget(w)
    w.printNames()
    
    


More information about the PyQt mailing list