PyQT: QDialog outside main thread?

  • Hi,

    I'am not into threading that much and so might have a stupid question. I'am trying to build a Viewer, usable in a data flow like python framework. Means I want to create a QDialog showing me some results in my script but it should not kill the main thread but continuing my script when closed. Is this possible and has anyone a hint for me how to do it?

    What I'am currently doing is this, but gives me the error:

    QApplication::exec: Must be called from the main thread

    from future import print_function

    from PyQt4 import QtGui
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4.QtOpenGL import *

    from Viewer_UI import Ui_Dialog

    from thread import start_new_thread

    import sys

    class Viewer(QDialog, Ui_Dialog):
    def init(self, data, parent=None):
    QDialog.init(self, parent)

        #assert isinstance(arrv, ArrayVector) = data
    def process(self):
        # dummy worker process
    finished = pyqtSignal()

    def main(data):
    window = Viewer(data)
    return qApp.exec_()

    def run(data, argv=sys.argv):
    app = QtGui.QApplication(argv)
    start_new_thread(main, (data, ))


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.