Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PyQT: QDialog outside main thread?

PyQT: QDialog outside main thread?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.7k Views
  • 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.
  • _ Offline
    _ Offline
    __patrice__
    wrote on last edited by
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved