52QVideoWidget::QVideoWidget(QWidget *parent)
54 , d_ptr(
new QVideoWidgetPrivate)
57 d_ptr->isEglfs = QGuiApplication::platformName().startsWith(
"eglfs"_L1, Qt::CaseInsensitive);
60 qWarning(
"QVideoWidget is not supported on eglfs");
61 d_ptr->fakeVideoSink =
new QVideoSink(
this);
63 d_ptr->videoWindow =
new QVideoWindow;
64 d_ptr->videoWindow->setFlag(Qt::WindowTransparentForInput,
true);
65 d_ptr->windowContainer = QWidget::createWindowContainer(d_ptr->videoWindow,
this, Qt::WindowTransparentForInput);
66 d_ptr->windowContainer->move(0, 0);
67 d_ptr->windowContainer->resize(size());
68 connect(d_ptr->videoWindow, &QVideoWindow::aspectRatioModeChanged,
this,
69 &QVideoWidget::aspectRatioModeChanged);
111void QVideoWidget::setFullScreen(
bool fullScreen)
114 if (isFullScreen() == fullScreen)
120 Qt::WindowFlags flags = windowFlags();
124 QPoint position = mapToGlobal(QPoint(0,0));
125 d->nonFullScreenFlags = flags & (Qt::Window | Qt::SubWindow);
126 d_ptr->nonFullscreenPos = pos();
128 flags &= ~Qt::SubWindow;
129 setWindowFlags(flags);
136 flags &= ~(Qt::Window | Qt::SubWindow);
137 flags |= d->nonFullScreenFlags;
138 setWindowFlags(flags);
141 move(d_ptr->nonFullscreenPos);
142 d_ptr->nonFullscreenPos = {};
164bool QVideoWidget::event(QEvent *event)
168 if (event->type() == QEvent::WindowStateChange) {
169 bool fullScreen =
bool(windowState() & Qt::WindowFullScreen);
170 if (fullScreen != d->wasFullScreen) {
171 emit fullScreenChanged(fullScreen);
172 d->wasFullScreen = fullScreen;
176 return QWidget::event(event);