[PyQt] Advices on embedding python in Qt/C++ application

Alexis Barbot alexis.barbot at gmail.com
Tue Aug 27 08:29:46 BST 2019

Thanks for these replies,

First of all, I had a look at PythonQt which indeed looked promising in my
case. However I had toubles to build it, so I skipped that solution. Now I
understand that this was probably caused by the compilation attempt with
mingw while using a binary python installer, obviously compiled using msvc.
Furthermore, I got some success with PyQt: after preparing all paths and
adding several flags to the configure command, I could perform the complete
build wihtout errors. I so tried to write a small piece of code to validate
my usage. It builds correctly, but it suddenly stop while running without
any error message. Here is the code:

#include <QDebug>
#include <Python.h>
#include <QDateTime>
#include <sipAPIQtCore.h>
#include <memory>

int main(int argc, char* argv[])
    qDebug() << "start";
    auto d = PyDict_New();
    auto test = std::make_unique<QDateTime>();
    auto pyTest = sipConvertFromType(test.get(), sipType_QDateTime,
    qDebug() << "end";
    return 0;

It sounds like everything is installed but I'm missing some initialization
step. Is that possible? Or maybe there's something else I should check/try?
Many thanks for your help.


Le lun. 26 août 2019 à 18:35, Andrew Cunningham <pyqt at a-cunningham.com> a
écrit :

> Alexis,
> You may want to look at PythonQT as a way to integrate python into a C++
> application.
> It happily co-exists with PyQT. Just make sure you are using the same QT
> version....
> Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190827/4c776c73/attachment.html>

More information about the PyQt mailing list