thp / pyotherside

Python Bindings for Qt 5 and Qt 6. Allows you to access a CPython 3 interpreter directly from your Qt QML user interface code.
https://thp.io/2011/pyotherside/
Other
364 stars 49 forks source link

I am manually adding PyOtherSide to my project via a submodule. #81

Closed pauldotknopf closed 7 years ago

pauldotknopf commented 7 years ago

This will help me debug issues that I may have with it. However, since Python.h contains keywords that are specific to qt, we must instead use the macros.

Side note, how are you able to use Python.h and the qt keywords in the same project? Python.h contains structs/properties that are reserved qt keywords. I see you are using the keywords. How?

thp commented 7 years ago

The Python 3.6 headers (and as far also the earlier ones) don't redefine any of those keywords:

% egrep '(slots|signals|emit)' include/python3.6m/*.h
include/python3.6m/Python.h:#include "typeslots.h"
include/python3.6m/moduleobject.h:  struct PyModuleDef_Slot* m_slots;
include/python3.6m/object.h:    PyType_Slot *slots; /* terminated by slot==0. */
include/python3.6m/object.h:    PyObject *ht_name, *ht_slots, *ht_qualname;
include/python3.6m/object.h:    /* here are optional user slots, followed by the members. */
include/python3.6m/pylifecycle.h:/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
include/python3.6m/setobject.h:The hash field of Unused slots is always zero.
include/python3.6m/setobject.h:The hash field of Dummy slots are set to -1
include/python3.6m/setobject.h:    /* The table contains mask + 1 slots, and that's a power of 2.

What kind of compile error do you get?

thp commented 7 years ago

Ah! Now I understand what you mean. Qt does redefine keywords such as slots and because of that, the Python headers that use slots as a variable name will get those redefined. You can work around this by including Python.h before any of the Qt headers.

thp commented 7 years ago

Work around: You can work around this by including Python.h before any of the Qt headers.