QVideoWidget stopped working as viewfinder after Qt upgrade 6.2.0->6.2.1 - bug?
Solved
Qt for Python
-
Hi all,
I have a code that uses QVideoWidget as a viewfinder for QCamera. Code snipped is below, here are my comments:- I use Linux for my tests;
- this code works ok with PySide6 6.2.0 - I see live image in viewfinder;
- with PySide6 6.2.1 the viewfinder is black;
- there are commented pieces of code - I added this to check 6.2.1 more and image is successfully saved if I press the button (i.e. QImageCapture itself works);
- no errors are printed by this code;
Does it mean I missed some change between 6.2.0 and 6.2.1? Or something is broken?
Code:
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QPushButton from PySide6.QtMultimedia import QCamera, QMediaCaptureSession, QImageCapture from PySide6.QtMultimediaWidgets import QVideoWidget from PySide6.QtGui import QImage class CameraWnd(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.layout = QVBoxLayout() self.viewfinder = QVideoWidget(self) self.layout.addWidget(self.viewfinder) self.viewfinder.setMinimumSize(720, 405) self.button = QPushButton(self) self.button.setText("Check state") self.layout.addWidget(self.button) self.wnd = QWidget(self) self.wnd.setLayout(self.layout) self.setCentralWidget(self.wnd) self.camera = QCamera() self.captureSession = QMediaCaptureSession() self.img_capture = QImageCapture(self.camera) self.captureSession.setCamera(self.camera) self.captureSession.setVideoOutput(self.viewfinder) self.captureSession.setImageCapture(self.img_capture) self.button.clicked.connect(self.on_button) self.img_capture.errorOccurred.connect(self.on_error) self.camera.errorOccurred.connect(self.on_cam_error) # self.img_capture.imageCaptured.connect(self.captured) self.camera.start() def on_button(self): if self.img_capture.isReadyForCapture(): print("READY") # self.img_capture.capture() else: print("NOT READY") def on_error(self, _id, _error, error_str): print(f"Error: {error_str}") def on_cam_error(self, _error, error_str): print(f"Error: {error_str}") # def captured(self, id: int, img: QImage): # print(id) # img.save('/home/user/test.png') def main(): app = QApplication() camera = CameraWnd() camera.show() return app.exec() if __name__ == '__main__': main()
-
Hi,
Since your code is pretty simple and does look correct, It looks like a regression.
-
@StarterKit I have compiled the official example https://doc.qt.io/qt-6/qtmultimedia-multimediawidgets-camera-example.html and I reproduce the error so it is clearly a bug.
-
@StarterKit You must report it as a QtMultimedia bug, not PySide6
-
@eyllanesc have you tried it on Linux also? or another OS?
-
@StarterKit On Linux, with Qt 6.2.0 it worked great but no longer on Qt 6.2.1
-