Re: Advices on embedding python in Qt/C++ application

Phil Thompson <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <[email protected]>
On 03/09/2019 17:23, Alexis Barbot wrote:
> Thanks Phil,
> 
> I recompiled PyQt5.13 against Qt5.12 mingw32. I had to modify the qmake
> generated .pro to add "QMAKE_CXXFLAGE += "-D_hypot=hypot", and add
> "-lpython" to "LIBS" to every sub project, but it finally compiled. Now 
> I'm
> trying to run an exemple as you said, but it crashes without 
> explainations.
> Here is the code sample:
> 
> #include <sip.h>
> #include <Python.h>
> #include <QDateTime>
> 
> ...
> 
> Py_Initialize();
> PyImport_ImportModule("sip");

You don't need this line ^^^^

> auto sipAPI_QtCore = reinterpret_cast<const
> sipAPIDef*>(PyCapsule_Import("PyQt5.sip._C_API", 0));
> PyImport_ImportModule("PyQt5.QtCore");
> auto type = sipAPI_QtCore->api_find_type("QDateTime");
> 
> Could someone confirm me this example should work, please?

You should have error checking on each of the last 3 lines. If they are 
working then debug it using whatever tools mingw provides.

Phil
_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.