diff --git a/include/wx/qt/frame.h b/include/wx/qt/frame.h index 4905911d79..ea515def5c 100644 --- a/include/wx/qt/frame.h +++ b/include/wx/qt/frame.h @@ -57,6 +57,8 @@ public: protected: virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE; + virtual QWidget* QtGetParentWidget() const wxOVERRIDE; + private: // Common part of all ctors. void Init() diff --git a/include/wx/qt/window.h b/include/wx/qt/window.h index 98608b1fa2..ace2a71711 100644 --- a/include/wx/qt/window.h +++ b/include/wx/qt/window.h @@ -215,6 +215,12 @@ protected: virtual bool DoPopupMenu(wxMenu *menu, int x, int y) wxOVERRIDE; #endif // wxUSE_MENUS + // Return the parent to use for children being reparented to us: this is + // overridden in wxFrame to use its central widget rather than the frame + // itself. + virtual QWidget* QtGetParentWidget() const { return GetHandle(); } + + QWidget *m_qtWindow; private: diff --git a/src/qt/frame.cpp b/src/qt/frame.cpp index 20c84d747a..e32bf8ec98 100644 --- a/src/qt/frame.cpp +++ b/src/qt/frame.cpp @@ -187,11 +187,16 @@ void wxFrame::SetWindowStyleFlag( long style ) GetQMainWindow()->setWindowFlags(qtFlags); } +QWidget* wxFrame::QtGetParentWidget() const +{ + return GetQMainWindow()->centralWidget(); +} + void wxFrame::AddChild( wxWindowBase *child ) { // Make sure all children are children of the central widget: - QtReparent( child->GetHandle(), GetQMainWindow()->centralWidget() ); + QtReparent( child->GetHandle(), QtGetParentWidget() ); wxFrameBase::AddChild( child ); } diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 7ccb774ab5..43bec0e3e9 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -437,7 +437,7 @@ bool wxWindowQt::Reparent( wxWindowBase *parent ) if ( !wxWindowBase::Reparent( parent )) return false; - QtReparent( GetHandle(), parent->GetHandle() ); + QtReparent( GetHandle(), static_cast(parent)->QtGetParentWidget() ); return true; }