Skip to content

Commit

Permalink
qtwinmigrate: Fix geometry offset
Browse files Browse the repository at this point in the history
Set the property "_q_embedded_native_parent_handle" on the
widget before calling winId() so that it takes effect
during native window creation.

The bug was unveiled by
qtbase/3035400f36731c400adb9204b94e9afe346a71b7.

Task-number: QTSOLBUG-196
Change-Id: I5dac836b2845de9833da46bfb72d07aafdf4896a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
  • Loading branch information
FriedemannKleint committed Jul 16, 2018
1 parent ee17851 commit 9568abd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qtwinmigrate/src/qwinwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void QWinWidget::init()
Q_ASSERT(hParent);

if (hParent) {
#if QT_VERSION >= 0x050000
setProperty("_q_embedded_native_parent_handle", WId(hParent));
#endif
// make the widget window style be WS_CHILD so SetParent will work
QT_WA({
SetWindowLong((HWND)winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
Expand All @@ -131,7 +134,6 @@ void QWinWidget::init()
})
#if QT_VERSION >= 0x050000
QWindow *window = windowHandle();
window->setProperty("_q_embedded_native_parent_handle", (WId)hParent);
HWND h = static_cast<HWND>(QGuiApplication::platformNativeInterface()->
nativeResourceForWindow("handle", window));
SetParent(h, hParent);
Expand Down

1 comment on commit 9568abd

@lynetta
Copy link

@lynetta lynetta commented on 9568abd Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you modernized this code base to compile in studio 2015 or higher? I'm new to windows environment, working mostly in Linux and looking to decrease my timeline to have qt widgets in a windows app.

Please sign in to comment.