[problem description]
to develop a graphical interface using pyqt5, you need to display videos and pictures in the same place in the window, that is, to display a picture after the video is played. My idea is to build a widget, the widgt as the VedioOutput, of the QMediaPlayer and create a label as a child control of the widget, and then insert the picture after playing the video. The code is as follows:
-sharp
self.widget1 = QtMultimediaWidgets.QVideoWidget(self.centralwidget)
self.widget1.setMinimumSize(QtCore.QSize(480, 400))
self.widget1.setAutoFillBackground(False)
self.widget1.setObjectName("widget1")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget1)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.img = QtWidgets.QLabel(self.widget1)
self.img.setMinimumSize(QtCore.QSize(704, 396))
self.img.setText("")
self.img.setScaledContents(True)
self.img.setObjectName("img")
self.horizontalLayout_2.addWidget(self.img)
...
-sharp
self.mediaPlayer = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface)
self.mediaPlayer.setVideoOutput(self.widget1)
self.mediaPlayer.setNotifyInterval(1000)
self.widget1.show()
...
-sharp
self.image = QtGui.QPixmap(path)
self.img.setPixmap(self.image)
self.img.show()
when I run on my local computer, pictures can appear after playing the video, but the magic is that after I move to the public computer, the image will be overwritten by the video, and the black screen cannot be displayed all the time. The raise method has been tried and has no effect. Local computers and public computers are both WIN10 systems, python and other versions are also the same.
what is the possible reason for asking the bosses for advice? Thank you very much!