Qt's documentation is quite good. Here are the official python Qt docs on the subject of slots in Qt 6 (PySide2): https://doc.qt.io/qtforpython-6/tutorials/basictutorial/signals_and_slots.html
In short you decorate them with @Slot(params) where params are a list of the Qt types your slot is expecting from a Qt signal. At least in Qt 6. There probably still is a Qt 5 version of this document somewhere. Although since Qt 5 is now EOL, it's harder to find those docs. Working with Qt in Python can be a bit jarring because it's very much a C++-oriented, typed library, with a pile of quirks. So a lot of that C++-ism bleeds through into the python bindings. Also there are sometimes interesting issues regarding object lifetimes since every python object is backed by a c++ object. Most of these issues have been solved over the years. Whatever the case, Qt Python code is never very "pythonic." But it gets the job done and is the best cross-platform UI toolkit there is. Although traditional QWidget-based UI bits aren't going anywhere, the future of Qt is very much QtQuick, which uses Javascript inside the UI itself with a declarative way of defining the UI. Similar to the idea of XAML, but more using a JSON and javascript -inspired syntax. But that's a story for another day. On 12/2/25 3:03 PM, Rich Shepard wrote: > On Tue, 2 Dec 2025, Thomas Passin wrote: > >> Why not? Nothing very complicated, please. But you should be learning >> PyQt6, not v5. There's not a huge difference but go with v6 since almost >> it's getting all the new development. > > Thomas, > > Thanks. Most questions are simple (and more Python than PyQt.). This desktop > currently runs PyQt5; during this month I'll upgrade the OS to the current > stable release and install either PyQt6 or PySide6. > > The question that prompted me to write is how to write a slot (funcion in > response > to a widget's signal/action.) The application is databased so accepting > entries on a form (dialog) using the 'Save' button will be a SQL query. What > I've not found is the method to call when the 'Close' button is pressed to > reject all entries and close the dialog box/window. > > Regards, > > Rich -- https://mail.python.org/mailman3//lists/python-list.python.org
