Oops, I was being too hasty. On more careful inspection (and a cup of coffee)
both objects you're connecting are in fact QMenu.
Maybe you can try with "old-style" connecting:
from PySide.QtCore import QObject, SIGNAL
...
QObject.connect(
self.m1, SIGNAL( 'aboutToShow()' ), self.aboutToShowHandler)
QObject.connect(
self.m2, SIGNAL( 'aboutToShow()' ), self.aboutToShowHandler)
Thomas Sturm kirjoitti 3.12.2010 kello 23.35:
> Now here is the core remaining problem, which I do not understand:
>
> In the code below, the aboutToShow.connect works for m1, which is an instance
> of QMenu but not for m2, which is an instance of a subclass of QMenu.
>
> I would be grateful for any tip!
>
> Thomas
>
> --
> Dr. habil. Thomas Sturm
> Departamento de Matematicas, Estadistica y Computacion
> Universidad de Cantabria, Santander, Spain
> Avda. Los Castros s/n, Room 1072, +34 693 251058
> http://personales.unican.es/sturmt/
>
> #!/usr/bin/env python
> import sys
> from PySide.QtGui import QApplication
> from PySide.QtGui import QMainWindow
> from PySide.QtGui import QMenu
>
> class Window(QMainWindow):
> def __init__(self):
> super(Window,self).__init__()
> self.m1 = QMenu(self)
> self.m1.aboutToShow.connect(self.aboutToShowHandler)
> self.m1.setTitle(self.tr("M1"))
> self.m2 = M2(self)
> self.m2.aboutToShow.connect(self.aboutToShowHandler)
> self.menuBar().addMenu(self.m1)
> self.menuBar().addMenu(self.m2)
> self.show()
>
> def aboutToShowHandler(self):
> print "received aboutToShow signal"
>
> class M2(QMenu):
> def __init__(self,parent=None):
> super(M2,self).__init__(parent)
> self.setTitle(self.tr("M2"))
>
> app = QApplication(sys.argv)
> mainwindow = Window()
> sys.exit(app.exec_())
>
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside