You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using PyQt5 to build a UI for my computer vision app. The app has six pages, and on the fourth page, I receive video frames from a backend thread that runs when the app reaches this page. However, I'm having trouble getting the QLabel on the fourth page to resize correctly and display the video frames in full screen.
Here is the code snippet that sends frames to the frontend:
classFourthPage(QWidget):
recording_finished=pyqtSignal()
switch_to_fifth_page=pyqtSignal()
def__init__(self, parent=None):
super().__init__(parent)
self.initUI()
definitUI(self):
self.setContentsMargins(0, 0, 0, 0)
# Set up the video label to take up the entire spaceself.video_label=QLabel(self)
self.video_label.setAlignment(Qt.AlignCenter)
self.video_label.setStyleSheet("background-color: transparent;") # Optional: Set transparent background# Set video_label to cover the entire widgetself.video_label.setGeometry(0, 0, self.width(), self.height())
self.click_player=QMediaPlayer()
# Install event filter to detect clicks on the video labelself.video_label.installEventFilter(self)
defresizeEvent(self, event):
# Ensure video_label resizes with the widgetself.video_label.setGeometry(0, 0, self.width(), self.height())
defstopRecording(self):
self.recording_finished.emit()
defplayClickSound(self):
self.click_player.setMedia(QMediaContent(QUrl.fromLocalFile("/path/to/Click.mp3")))
self.click_player.setVolume(100)
self.click_player.play()
defhandleMouseClick(self):
self.stopRecording()
self.playClickSound()
QTimer.singleShot(500, self.switch_to_fifth_page.emit)
defeventFilter(self, source, event):
ifevent.type() ==QEvent.MouseButtonPressandsource==self.video_label:
self.handleMouseClick()
returnTruereturnsuper().eventFilter(source, event)
Here is the main class that controls the flow of the app:
Problem: The QLabel on the fourth page does not resize correctly to display the video frames in full screen. I've tried different spacing and margin options, but none of them work. It gives white borders on left, right and top
Question: How can I ensure that the QLabel resizes correctly and displays the video frames in full screen on the fourth page?
Any help or suggestions would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
I'm using PyQt5 to build a UI for my computer vision app. The app has six pages, and on the fourth page, I receive video frames from a backend thread that runs when the app reaches this page. However, I'm having trouble getting the
QLabel
on the fourth page to resize correctly and display the video frames in full screen.Here is the code snippet that sends frames to the frontend:
Here is the class for the fourth page:
Here is the main class that controls the flow of the app:
Problem: The
QLabel
on the fourth page does not resize correctly to display the video frames in full screen. I've tried different spacing and margin options, but none of them work. It gives white borders on left, right and topQuestion: How can I ensure that the
QLabel
resizes correctly and displays the video frames in full screen on the fourth page?Any help or suggestions would be greatly appreciated!
The text was updated successfully, but these errors were encountered: