title: PySide and QProgressBar update in a different thread
body: <p>This may be a little long post, so, thanks in advance to be with me till the end. Here is the problem, (i think a fairly basic one, just my inexperience with PiSide and Qt making it harder for me.) I have a main window with one menu item, suppose "Process". the code is following -</p>
  
  <pre><code>from PySide import QtCore, QtGui
  
  class Ui_MainWindow(object):
  
        def setupUi(self, MainWindow, AppObj):
              .
              .
              self.statusbar = QtGui.QStatusBar(MainWindow)
              self.statusbar.setObjectName("statusbar")
              MainWindow.setStatusBar(self.statusbar)
              .
              .
              .
             self.actionProcess = QtGui.QAction(MainWindow)
             self.actionProcess.setObjectName("actionProcess")
             self.actionProcess.triggered.connect(self.myappObj.menuActionProcess) 
             .
  </code></pre>
  
  <p>Here self.myappobj refers to a app class I have created which acts as the main logic controller for my app. The code -</p>
  
  <pre><code>from PySide import QtCore, QtGui
  from MainWindow import Ui_MainWindow
  
  class App(QtGui.QDialog):
        def __init__(self, parent=None):
            self.__mainWindow = QtGui.QMainWindow()
            self.__mainWindowDesignContext = Ui_MainWindow()
            self.__mainWindowDesignContext.setupUi(self.__mainWindow, self)
            self.__mainWindow.show()
        def menuActionProcess(self):
            self.processThread = BatchProcesser()
            self.progressBar = QtGui.QProgressBar()
            statusBar.addWidget(self.progressBar)
            self.progressBar.show()
            self.progressBar.setMinimum(0)
            self.progressBar.setMaximum(100)
            QtCore.QObject.connect(self.processThread, QtCore.SIGNAL("progress(int)"),self.progressBar, QtCore.SLOT("setValue(int)"), QtCore.Qt.DirectConnection)
            if not self.processThread.isRunning():
                self.processThread.exiting = False
                self.processThread.start()
  </code></pre>
  
  <p>So, it is easy to see that what i am trying to do here is to create a main window. Add a menu there called "Process", clicking on which should trigger the callback menuActionProcess method in the app class, where I am making a progress bar and attaching it with the Status Bar of my main window (The actual code has many other things, what i give here is the necessary parts rearranged as an pseudo example)
  and finally in the BatchProcesser class mentioned in the above code, I am doing this - </p>
  
  <pre><code>from PySide.QtGui import *
  from PySide.QtCore import *
  
  class BatchProcesser(QThread):
       __errorHappened = False
       def __init__(self, parent=None):
           QThread.__init__(self, parent)
           self.exiting = False
       def run(self):
           for a in range(101):
              print a
              QThread.msleep(100)
              self.emit(SIGNAL("progress(int)"), a)
              print a
  </code></pre>
  
  <p>In my understanding this should update the Progress Bar attached to the Status Bar in a different thread than the main thread. This will allow the user to interact with the GUI freely.</p>
  
  <p>Right now, If i try to rin this, everything is fine until i hit the Process menu. Then, the progress bar appeases but does not update and the console is full with error - </p>
  
  <blockquote>
    <p>0 QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>0</p>
    
    <p>1</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>QPixmap: It is not safe to use pixmaps outside the GUI thread</p>
    
    <p>[xcb] Unknown request in queue while dequeuing</p>
    
    <p>[xcb] Most likely this is a multi-threaded client and XInitThreads has
    not been called</p>
    
    <p>[xcb] Aborting, sorry about that.</p>
    
    <p>python: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion
    `!xcb_xlib_unknown_req_in_deq' failed.</p>
    
    <p>Aborted (core dumped)</p>
  </blockquote>
  
  <p>Any help is very much required for me. I am unable to find out and/ot point the original reason of the error and fix the same.</p>