[PyQt] QCoreApplication.aboutToQuit not a signal...

David Cortesi davecortesi at gmail.com
Thu Dec 15 23:38:10 GMT 2016


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 )

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...


[1] http://doc.qt.io/qt-5/qcoreapplication.html#aboutToQuit

[2]
http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#defining-new-signals-with-pyqtsignal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20161215/33fb4587/attachment.html>


More information about the PyQt mailing list