Skip to content

Commit

Permalink
Fix the OpenGLScreenGrabber for QQuickWidgetOffscreenWindow in Qt6.8+
Browse files Browse the repository at this point in the history
For me at least, the y offset has to be 0, otherwise we grab an offset
part of the image. Furthermore, the x offset has to be hidpi adapted
too.

I cannot test the other Qt versions, so I'll assume this code used to
work fine there and only touch this for Qt 6.8+
  • Loading branch information
milianw authored and Waqar144 committed Jan 3, 2025
1 parent 33d081a commit 219f2ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/quickinspector/quickscreengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,14 +633,19 @@ void OpenGLScreenGrabber::windowAfterRendering()
const auto viewportHeight = viewport[3];
yOff = viewportHeight - windowBottom;
#else
const auto windowBottom = m_renderInfo.windowSize.height();
const auto rc = QQuickWindowPrivate::get(m_window)->renderControl;
QPoint offset;
rc->renderWindow(&offset);

xOff = offset.x();
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
yOff = 0;
xOff = static_cast<int>(std::floor(xOff * m_renderInfo.dpr));
#else
const auto viewportHeight = viewport[3];
const auto windowBottom = m_renderInfo.windowSize.height();
yOff = viewportHeight - windowBottom - offset.y();
xOff = offset.x();
#endif
#endif
}
#endif
Expand Down

0 comments on commit 219f2ef

Please sign in to comment.