[PyQt] New Feature - Keyword Arguments for Properties and Signals

Phil Thompson phil at riverbankcomputing.com
Mon Sep 7 08:57:42 BST 2009


The current SIP and PyQt snapshots support the use of using keyword
arguments when creating an instance of a QObject sub-class to initialise Qt
properties and to connect signals.

For example, the following calls...

    act = QAction("Save", parent)
    act.setShortcut(QKeySequence.Save)
    act.setStatusTip("Save the document")
    act.triggered.connect(self.save)

...can be replaced by...

    act = QAction("Save", parent, shortcut=QKeySequence.Save,
            statusTip="Save the document", triggered=self.save)

This will automatically work for any Qt property and signal (eg. in KDE
classes) without needing to change any .sip files.

Phil


More information about the PyQt mailing list