[PyKDE] Stuck newbie

Johannes Graumann johannes_graumann at web.de
Tue Oct 10 12:05:29 BST 2006


Thanks for your help! The clueless (but ambitious) one is one step further ;0)

Can somebody tell me how to properly connect my 'actionQuit_Ctrl_Q' with a quit signal for the whole Application execution loop?

Thanks for your patience,

Joh

class ElNotes(QtGui.QApplication):
    def __init__(self,args):
      QtGui.QApplication.__init__(self, args)
      self.maindialog = uic.loadUi("ElNotes_GUI.ui")
      self._connectSlots()
      self.maindialog.show()
      self.exec_()
    def _connectSlots(self):
      self.connect(self.maindialog.actionQuit_Ctrl_Q,QtCore.SIGNAL("clicked()"),self.slotQuit_Ctrl_Qclicked())
    def slotQuit_Ctrl_Qclicked(self):
      self.connect(QtCore.SLOT("quit()"))

> -----Ursprüngliche Nachricht-----
> Von: David Boddie <david at boddie.org.uk>
> Gesendet: 09.10.06 23:47:21
> An: pykde at mats.imk.fraunhofer.de
> Betreff: Re: [PyKDE] Stuck newbie


> On Monday 09 October 2006 09:41:59 +0200, Johannes Graumann wrote:
> 
> > Can somebody please give me a hint why the amateurish code below segfaults?
> > What am I doing wrong and how to fix it?
> 
> [...]
> 
> > class ElNotes:
> >     def __init__(self,args):
> >       self = QtGui.QApplication(args)
> >       self.maindialog = uic.loadUi("ElNotes_GUI.ui")
> >       self.maindialog._connectSlots()
> >       self.maindialog.show()
> >       self.exec_()
> >     def _connectSlots(self):
> >       self.maindialog.connect(self.actionQuit_Ctr_Q,
> >                               SIGNAL("clicked()"),
> >                               self.slotQuit_Ctr_Qclicked)
> 
> [...]
> 
> > if __name__=="__main__":
> >   ElNotes = ElNotes(sys.argv)
> 
> It's slightly unusual to use a class to enter the main loop like this,
> but there's nothing actually wrong with this approach. The problem may
> be that you're reassigning self in the __init__() method, and the class
> doesn't inherit from QApplication.
> 
> It would be more correct to subclass QApplication instead:
> 
> class ElNotes(QtGui.QApplication):
>     def __init__(self,args):
>       QtGui.QApplication.__init__(self, args)
>       self.maindialog = uic.loadUi("ElNotes_GUI.ui")
>       self.maindialog._connectSlots()
>       self.maindialog.show()
>       self.exec_()
>     def _connectSlots(self):
>       self.maindialog.connect(self.actionQuit_Ctr_Q,
>                               SIGNAL("clicked()"),
>                               self.slotQuit_Ctr_Qclicked)
> 
> I haven't actually tried this out, but it should work. Let us know whether
> it did or not.
> 
> David
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066




More information about the PyQt mailing list