diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp index 3d5e5c8300d2ef0993cc80a1d8086250315c14e8..60a968813cc33d98041f9d70c110e60191756702 100644 --- a/src/multimediawidgets/qvideowidget.cpp +++ b/src/multimediawidgets/qvideowidget.cpp @@ -55,6 +55,9 @@ #include <qboxlayout.h> #include <qnamespace.h> +#include <qwindow.h> +#include <private/qhighdpiscaling_p.h> + using namespace Qt; QT_BEGIN_NAMESPACE @@ -372,11 +375,23 @@ QSize QWindowVideoWidgetBackend::sizeHint() const return m_windowControl->nativeSize(); } +void QWindowVideoWidgetBackend::updateDisplayRect() +{ + QRect rect = m_widget->rect(); + if (QHighDpiScaling::isActive()) { + const qreal factor = QHighDpiScaling::factor(m_widget->windowHandle()); + if (!qFuzzyCompare(factor, qreal(1))) { + rect = QRectF(QPointF(rect.topLeft()) * factor, + QSizeF(rect.size()) * factor).toRect(); + } + } + m_windowControl->setDisplayRect(rect); +} + void QWindowVideoWidgetBackend::showEvent() { m_windowControl->setWinId(m_widget->winId()); - - m_windowControl->setDisplayRect(m_widget->rect()); + updateDisplayRect(); #if defined(Q_WS_WIN) m_widget->setUpdatesEnabled(false); @@ -392,12 +407,12 @@ void QWindowVideoWidgetBackend::hideEvent(QHideEvent *) void QWindowVideoWidgetBackend::moveEvent(QMoveEvent *) { - m_windowControl->setDisplayRect(m_widget->rect()); + updateDisplayRect(); } void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) { - m_windowControl->setDisplayRect(m_widget->rect()); + updateDisplayRect(); } void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) diff --git a/src/multimediawidgets/qvideowidget_p.h b/src/multimediawidgets/qvideowidget_p.h index 15aaa5a6075ddfaf389787becf726606694b5680..039ace24e031a372a3dc0c44630c3f0bc304a315 100644 --- a/src/multimediawidgets/qvideowidget_p.h +++ b/src/multimediawidgets/qvideowidget_p.h @@ -211,6 +211,8 @@ public: #endif private: + void updateDisplayRect(); + QMediaService *m_service; QVideoWindowControl *m_windowControl; QWidget *m_widget;