Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    PyQT: QDialog outside main thread?

    General and Desktop
    1
    1
    1538
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • _
      __patrice__ last edited by

      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)
      self.setupUi(self)

          #assert isinstance(arrv, ArrayVector)
          self.data = data
      
      
      def process(self):
          # dummy worker process
          self.label.setText(QString(self.data))
          self.finished.emit()
      
      finished = pyqtSignal()
      

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

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

      Thx

      1 Reply Last reply Reply Quote 0
      • First post
        Last post