[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QCoreApplication.aboutToQuit not a signal...
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2016-12-16 0:42:02
Message-ID: F138D2F1-BA85-4FB9-A657-494475E7A8FC () riverbankcomputing ! com
[Download RAW message or body]
On 15 Dec 2016, at 11:38 pm, David Cortesi <davecortesi@gmail.com> wrote:
>
> Per the Qt docs [1], aboutToQuit is a signal emitted by QCoreApplication.
>
> However when I attempt this in a QWidget-based class,
>
> class Mine( QWidget ) :
> def __init__( self, parent ) :
> super().__init__( Parent )
> QCoreApplication.aboutToQuit.connect( self.quittin )
How does it know which QCoreApplication instance is emitting the signal?
> this produces an error, 'PyQt5.QtCore.pyqtSignal' object has no attribute 'connect' -- which \
> tells me that QCoreApplication is not a signal but a PyQt signal factory (?) so, following \
> the directions in [2]:
> class Mine( QWidget ) :
> about_to_quit = QCoreApplication.aboutToQuit()
> def __init__( self, parent ) :
> super().__init__( Parent )
> about_to_quit.connect( self.quittin )
>
> Nope, that gets the error "native Qt signal is not callable" -- so it isn't a pyqtSignal \
> after all, it's a real signal.
> So then accidentally I entered this:
>
> class Mine( QWidget ) :
> about_to_quit = QCoreApplication.aboutToQuit # <-- no parens!
> def __init__( self, parent ) :
> super().__init__( Parent )
> about_to_quit.connect( self.quittin )
>
> That executes without error! (So when it is assigned to a class variable, \
> QCoreApplication.aboutToQuit somehow acquires a .connect attribute?)
> But however alas -- no signal is delivered, or at any rate self.quittin() is never entered.
>
> So I could use some enlightenment here...
connect() is a method of bound signals, so...
QCoreApplication.instance().aboutToQuit.connect(self.quittin)
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://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