Problem using QGraphicsVideoItem with QOpenGLWidget
I'm working on a QWidgets application that uses a QGraphicsView with, among other items, a QGraphicsVideoItem. Currently, we're using a QGLWidget as the viewport for the QGraphicsView.
This works well, but we're now porting part of the application over to QtQuick. We'd like to do the port in steps, so preferable do not want to touch the QGraphicsView/video part yet. However, it seems that switching to the QGraphicsView and then back to the QtQuick UI (embedded using QWidget::createWindowContainer(QQuickView*, QWidget*) ) causes serious issues, as the QtQuick UI will not respond to mouse clicks anymore.
We've been doing some experimenting, and found out that not using a QGLWidget as the viewport for the graphics view fixed this. However, when using a QOpenGLWidget as the viewport, the video is no longer shown. Only a light blue square.
I'm probably missing something obvious or doing something silly. The change in the graphics view code is this:
auto * viewPortWidget = new QGLWidget(QGLFormat(QGL::SampleBuffers), this)
QSurfaceFormat format = QSurfaceFormat::defaultFormat(); format.setDepthBufferSize(0); format.setSamples(4); auto* viewPortWidget = new QOpenGLWidget(this); viewPortWidget->setFormat(format);
We'd like to find a solution for one of the two issues.
- Let QtQuick still take mouse clicks after using the graphics view,
- Use graphics view with QOpenGLWidget and QGraphicsVideoItem.
By the way, were presenting QVideoFrame objects with QVideoFrame::Format_YUV420P format. We've checked that the videosurface supports the format.
Another thing: This is on Mac OS X 10.13, with Qt 5.10.
Example of what it looks like:
Thank you for taking the time to read this.
I was wondering if you are .1 version away from fix.
@mrjj You're right, we're on 5.10.0. We'll do the update to 5.10.1 (or 5.11) and send an update.
I cross fingers it was just a bug and it it will just work in the later version :)
@mrjj Thanks a lot for your quick reply. Upgrading to 5.11 did the trick.
Super good to hear.
Thank you for the feedback.