Hi -
Menus in PyQt4 work fine when a separate action is created and assigned
to a menu item, but there is a problem when defining the action within
an overloaded QMenu.addAction() method. The menu gets created but then
gives a segmentation fault when the menu item is actuated.
I've attached a short example that illustrates the problem. The first
item in the context menu (from a separate QAction) works fine, but the
second one (using the internal action) causes a seg fault.
I'm using the 20060111 snapshot.
Thanks,
Doug.
#!/usr/bin/env python
import sys
from PyQt4 import QtCore, QtGui
class MenuTest(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('Right click for context menu')
workingAction = QtGui.QAction('&Working Action', self)
self.connect(workingAction, QtCore.SIGNAL('triggered()'), self.works)
self.menu = QtGui.QMenu(self)
self.menu.addAction(workingAction)
self.menu.addAction('&Broken Action', self.broken)
def works(self):
print 'This action works'
def broken(self):
print 'This menu item is broken'
def contextMenuEvent(self, event):
self.menu.exec_(event.globalPos())
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = MenuTest()
win.show()
app.exec_()
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde