Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Change pixmap image with another image



  • i want to change pixmap image with another image, iam newbie in python

    def detect1(self):
       image_path = "test/"+str(self.file_name[self.image_index])
       image = cv2.imread(image_path)
       .
       .
       cv2.imwrite(("test/"+str(self.file_name[self.image_index])),image)
       self.photo_img.setPixmap(QtGui.QPixmap("test/"+str(self.file_name[self.image_index])))
    
    def crr (self):
            if self.index%60==17:
                self.photo_img.setPixmap(QtGui.QPixmap("test/crr_img25.jpg"))
            if self.index%60==18: 
                self.photo_img.setPixmap(QtGui.QPixmap("test/crr_img26.jpg"))
    

    in my plan, pixmap display image ('img25).jpg') that index 17, pixmap image should be display ('crr_img25.jpg'). I tried my code when running until def crr , suddenly the main window closes. how to solve it? is my code wrong?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you get any error message ?



  • @SGaist no message, just python shell is written 'restart'


  • Lifetime Qt Champion

    Can you provide a minimal runnable script that shows that behaviour ?


Log in to reply