title: How to fix custom messagebox to work in a new thread from parent python pyqt5
body: <p>I have design my own message box in pyqt5 it worked fine.I remove all except the essential part.Here is my code</p>
  <pre><code>import sys
  from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  from PyQt5.QtWidgets import  QApplication,QWidget,QPushButton,QDialog,QFrame,QLabel,QTextEdit
  from threading import Thread
  class messagebox():
      def __init__(self,parent):
          self.parent=parent
          self.parent_width=self.parent.geometry().width()
          self.parent_height=self.parent.geometry().height()
      #This method will flash the messagebox dialog when we click on parent    
      def flash(self,event):
                      QTimer.singleShot(50,lambda:self.toolbar.setStyleSheet(&quot;background-color: blue;\n&quot;
          &quot;border-top-left-radius: 20px;\n&quot;
          &quot;border-top-right-radius: 20px;\n&quot;
          &quot;&quot;) )
                      QTimer.singleShot(120, lambda:self.toolbar.setStyleSheet(&quot;background-color: red;\n&quot;
          &quot;border-top-left-radius: 20px;\n&quot;
          &quot;border-top-right-radius: 20px;\n&quot;
          &quot;&quot;) )           
         
      def showinfo(self,title=&quot;ShowInfo&quot;,msg=&quot;Hello,There!&quot;):
          self.value=None
          self.pop = QDialog()
          self.pop.setGeometry(500,200,454,165)
          self.msg=msg
          self.pop.mousePressEvent=self.click
          self.pop.mouseMoveEvent=self.move
          self.frame = QFrame(self.pop)
          self.frame.setStyleSheet(&quot;background-color: #1b1b1b;\n&quot;
              &quot;border-bottom-left-radius: 20px;\n&quot;
              &quot;border-bottom-right-radius: 20px;\n&quot;
              &quot;&quot;)
          self.frame.setGeometry(0,30,454,134)
          self.toolbar = QFrame(self.pop)
          self.toolbar.setStyleSheet(&quot;background-color:red;\n&quot;
              &quot;border-top-left-radius: 20px;\n&quot;
              &quot;border-top-right-radius: 20px;\n&quot;
              &quot;&quot;)
          self.toolbar.setGeometry(0,0,454,30)
          #This makes the window to frameless
          self.pop.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)                   
          self.pop.setAttribute(Qt.WA_TranslucentBackground, True)
          #self.cover will Cover a frame to its parent entirely
          self.cover=QFrame(self.parent)   
          self.cover.resize(self.parent_width,self.parent_height)
          self.cover.setStyleSheet(&quot;background-color:transparent;&quot;)
          #you can see the frame by setting background to a color
          self.cover.show()
          self.cover.mousePressEvent=self.flash
          b1 = QPushButton(&quot;Ok&quot;,self.frame)
          b1.setStyleSheet('''QPushButton {background-color: red;
          border-style: outset;
          border-width: 2px;
          border-radius: 10px;
          border-color: beige;
          font: bold 14px;
          min-width: 60px;
          min-height: 25px;
          }''''''QPushButton:pressed{background-color: green;
          border-style: inset;}''')
          b1.move(350,100)
          b1.clicked.connect(self.on_close)
          self.pop.setWindowTitle(&quot;Dialog&quot;)
          self.pop.setWindowModality(Qt.WindowModal)
          self.pop.exec_()
          return self.value
      def on_close(self):
          self.value=True
          self.cover.deleteLater()
          self.pop.close()
      # move and click  methods are used to drag the dialog   
      def move(self, event):
              if event.buttons() ==Qt.LeftButton:
                      deltax = event.x()- self.xp
                      deltay = event.y() - self.yp
                      x = self.pop.x() + deltax
                      y = self.pop.y() + deltay
                      width,height=int(self.pop.geometry().width()),int(self.pop.geometry().height())
                      self.pop.setGeometry(int(x),int(y),width,height)
      def click(self, event):
             if event.buttons() == Qt.LeftButton:
                 self.xp=event.x()
                 self.yp=event.y()      
  def window():
         app = QApplication(sys.argv)
         w = QWidget()
         w.setGeometry(100,100,400,400)
         b = QPushButton(w)
         b.setText(&quot;Hello World!&quot;)
         b.move(50,50)
         messbox=messagebox(w)
         def run(): 
                 h=messbox.showinfo('hello','how r u?')
                 print(h) 
         #Thread(target=run).start() 
         b.clicked.connect(run)
         w.setWindowTitle(&quot;PyQt Dialog demo&quot;)
         w.show()
         sys.exit(app.exec_())    
  if __name__ == '__main__':
     window()
  </code></pre>
  <p>but the only problem is when I called the messagebox method like <code>messbox.showinfo()</code> from a thread it says can't create connection because child is in new thread.I have gone through Various example on this website about worker thread.but I can't understand worker thread  properly.Here i commented out 'Thread part' and call through button click.  Can any one make me understand please?Thank u!!!</p>