An alternative to the accepted answer:
Since Qt uses the slots
as a reserved keywords there is a clash with the declaration of the slots
member of the PyType_Spec
struct in the Python API.
Qt can be instructed to not use the normal moc keyword, and this will remove the clash. This is done by adding the following to your project file:
CONFIG += no_keywords
The drawback is then that you will need to refer to the corresponding Qt macros instead of the previous keywords.
Thus the following replacements will be needed for the Qt side:
signals -> Q_SIGNALS
slots -> Q_SLOTS
emit -> Q_EMIT
This is explained in the Qt docs on signals and slots on the section Using Qt with 3rd Part Signals and Slots.
PS: This is normally a good option when starting a new project, not when adding Python to an existing code base that uses the Qt keywords extensively.