Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawning process with another Qt app using multiprocessing from Python side #64

Open
estan opened this issue May 3, 2016 · 0 comments

Comments

@estan
Copy link

estan commented May 3, 2016

I'm probably missing something obvious, but with the test case

test.py

from multiprocessing import Process

def run_app():
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWidgets import QMainWindow

    app = QApplication([__file__])

    window = QMainWindow()
    window.show()

    app.exec_()

process = Process(target=run_app)
process.start()

test.qml

import QtQuick 2.4

import io.thp.pyotherside 1.4

Python {
    Component.onCompleted: {
        addImportPath(Qt.resolvedUrl('.'));
        importModule('test', function () {
            console.log('test.py imported');
        });
    }
}

running qmlscene test.qml gives

estan@newton:~$ qmlscene test.qml 
qml: test.py imported
WARNING: QApplication was not created in the main() thread.

and nothing shows up.

Running python3 test.py works fine of course.

Any idea why QApplication is giving a warning about not being created in the main thread? Both QApplications involved here (the one I spawn, and the one that drives the QML application) are created in completely different processes, so they should both be in the main thread of their respective processes, right?

(Some background, since I know this looks like a very contrived example: I'm working on the HMI GUI for an analysis machine. I communicate with the machine backend scripts using ZeroMQ sockets. When not running on the machine itself, I have a little simulator tool I built using Qt to simulate ZeroMQ messages from the machine. So for convenience while developing, I thought I'd just fire up the simulator process using multiprocessing from the Python side of my QML/pyotherside frontend, so that I get them both launched side by side.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant