Important: Please read the Qt Code of Conduct -

Communicating between Qt c++ program and another Python Qt program

  • Hi there,

    maybe an oddly specific question, but is it possible to influence a running Qt program made in C++,
    by a python script using Qt python bindings (Either PyQt or Pyside). I did some googling and did find about PythonQt,
    but that seemed quite limited.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What kind of influence do you have in mind ?

    Depending on that there might different techniques.

  • Hi,

    At first it would mostly come down to using setting text, adjust styles (Add / remove colored background of widgets) and things like that. Additionally I'd like to create new widgets (QDockWidgets, plus whatever their contents may be, mostly general layouts, text, labels and perhaps some dials)

    Basically I'm used to PyQt5 (or Pyside2) but will now have to extend a C++ Qt4 application and prefer to do as much as possible in Python (and as pythontic as possible), because I'm much more experienced in that. I do have access the to the QMainWindow through a plugin for the application, and ideally basically all finding children of existing widgets, adjusting and so would be done as much in python as possible (From just passing in the QMainWindow).

    It's more a "general advice" of what maybe others have done to do something similar. Maybe PythonQt would actually work okay, another thing I found was lthis stackoverflow answer

  • Lifetime Qt Champion

    For PySide2 / C++, see the example in this blog post.

    Qt 4 ? Are you locked to that old version ? It has reached end of life a long time ago.

  • @SGaist
    Unfortunately I am locked into Qt4 with the program itself. Heck, I was even hoping I could somehow influence this Qt4 app by some external python app running Pyside2. I have no idea how any of the underlying Qt infrastructure works, but that seems very far from possible (at least for me)

    My experience with PyQt5 and Pyside2 has been super pleasant and I feel really comfortable in Python, and not comfortable at all in C++, so that's why I'm looking around if there's an alternative.

    Ill probably give this a go for starters:

Log in to reply