[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] PyQt 4.10.2 Bug
From:       Casey Vanover <cvanover () rhythm ! com>
Date:       2013-08-15 18:54:57
Message-ID: 520D2401.3090905 () rhythm ! com
[Download RAW message or body]

I recently tried to upgrade to the newest version of PyQt4 and 
encountered an "interesting" bug. The use case is this: I have a 
QMenuBar created in C++. I'm creating a QtGui.QMenu in python and adding 
subclasses (called _MenuItem) of QtGui.QAction to them. It looks 
something like this:

<pseudocode>
# get the menu bar (originally created in C++ code)
menuBar = getMainWindow().menuWidget().findChild(QtGui.QMenuBar)

# add our python menu
menu = QtGui.QMenu("foo", menuBar)

# add our subclass of QtGui.QAction. the action is parented to 'menu'
action = _MenuItem("test", menu)
menu.addAction(action)
</pseudocode>

At this point, if I print "menu.actions()", I'll get something like this:

[<_MenuAction object at 0x5090628>]

However, if I don't keep my own reference to 'menu' or 'action' 
(relying, instead, on Qt's own reference counting system), when I leave 
the function I'll get this:

menu = getMenu("test")
print menu.actions()

# [<PyQt4.QtGui.QAction object at 0x5090628>]


So, it appears it lost the typeinfo of the subclass. More importantly 
(for me, at least), the action no longer behaves like an instance of the 
subclass. The triggered signal no longer calls the custom function in 
the class it was connected to. For the record, this worked in my 
previous version which was:

sip = 4.10.2
PyQt = 4.7.3






_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic