title: how to load an image in label when button pressed PyQt5
body: <p>I am new in programming in PyQt and when i run this code then pres button the window always get notresponding.</p>
  
  <p>and second question how can i load image in label when button pressed, i spend 3hours to get a question but i didn't get answer :((
  how to fix it and sorry before my english bad </p>
  
  <pre><code>import sys
  import cv2
  from PyQt5 import QtCore,QtWidgets
  from PyQt5.QtCore import pyqtSlot
  from PyQt5.QtGui import QImage,QPixmap
  from PyQt5.QtWidgets import QDialog,QApplication,QMainWindow
  from PyQt5.uic import loadUi
  
  class ShowImage (QMainWindow):
      def __init__(self):
          super(ShowImage,self).__init__()
          loadUi('ganteng.ui',self)
          self.image=None
          self.loadButton.clicked.connect(self.loadClicked)
  
  @pyqtSlot()
  def loadClicked(self):
      self.loadImage('2.jpg',cv2.IMREAD_GRAYSCALE)
  
  def loadImage(self,Flname):
      self.image=cv2.imread(flname)
      self.displayImage()
  
  def displayImage(self):
      qformat=QImage.Format_Indexed8
  
      if len(self.image.shape)==3:
          if (self.image.shape[2])==4:
              qformat=QImage.Format_RGBA8888
  
          else:
              qformat=QImage.Format_RGB888
  
              img=QImage(self.image,self.image.shape[1],self.image.shape[0],self.image.strides[0],qformat)
              img=img.rgbSwapped()
  
              self.imgLabel.serPixmap (QPixmap.fromImage(img))
              self.imgLabel.setAlignment (qtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
  
  app=QtWidgets.QApplication(sys.argv)
  window=ShowImage()
  window.setWindowTitle('gambar')
  window.show()
  app.exec_()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Btu6B.png" rel="nofollow noreferrer">this the ui window</a></p>