title: Multiprocessing: It is not safe to use pixmaps outside the GUI thread pyside
body: <p>I am building a simple GUI and trying to learn multiprocessing. In my GUI the capture button captures a frame and puts it inside the gui within a frame or a declared space(Qlabel). I did read the other posts in SO but didn't quiet understand how to use it in my program.</p>
  
  <p>When the error said not safe to use outside GUI, I tried </p>
  
  <pre><code>    print(multiprocessing.current_process())
  </code></pre>
  
  <p>which indicates that my QPixmap is running in the main thread. This is my program</p>
  
  <pre><code>import examplegui
  from PySide.QtGui import *
  from PySide.QtCore import *
  import sys
  import multiprocessing
  import numpy as np
  import cv2
  from multiprocessing import Queue
  
  def image_capture():
      print(multiprocessing.current_process())
      print("starting img proc")
      cap = cv2.VideoCapture(0)
      cap.set(cv2.CAP_PROP_FRAME_WIDTH, 641)
      cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 351)
      ret, frame = cap.read()
      cap.release()
  
      if ret == True:
          cv2.imwrite('frame.png', frame)
          return frame
  
  class Maindialog(QMainWindow,examplegui.Ui_MainWindow):
      pass_arguments = Signal(list)
  
      def __init__(self,parent = None):
          super(Maindialog,self).__init__(parent)
          self.setupUi(self)
          self.pool = multiprocessing.Pool(processes=4)
          self.connect(self.excel_file,SIGNAL("clicked()"),self.apply_connection)
      # self.pass_arguments.connect
  
  
      def apply_connection(self):
          print(multiprocessing.current_process())
          result = self.pool.apply_async(image_capture,callback=self.show_img)
  
      def show_img(self,result):
          print(multiprocessing.current_process())
          # print(result.type)
          cv2.imshow("img",result)
          image = QImage(result, result.shape[1], result.shape[0], result.strides[0], QImage.Format_RGB888)
          self.vidimg.setPixmap(QPixmap.fromImage(image))            
          cv2.waitKey(0)
  
      if __name__ == '__main__':
          app = QApplication(sys.argv)
          window = Maindialog()
          window.show()
          sys.exit(app.exec_())
  </code></pre>
  
  <p>I did an cv2.imshow to make sure the image is being run,but I need that image inside the GUI.When I run the prog I get the error</p>
  
  <pre><code> QPixmap: It is not safe to use pixmaps outside the GUI thread
   QPixmap: It is not safe to use pixmaps outside the GUI thread
   QPixmap: It is not safe to use pixmaps outside the GUI thread
  </code></pre>
  
  <p>Can someone please tell me where I am going wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/bTRtf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bTRtf.png" alt="enter image description here"></a></p>