Make Reparent() work for wxFrame in wxQt
Use the correct parent window, i.e. the one of the central widget and not of the frame itself.
This commit is contained in:
@@ -57,6 +57,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
|
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
|
||||||
|
|
||||||
|
virtual QWidget* QtGetParentWidget() const wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Common part of all ctors.
|
// Common part of all ctors.
|
||||||
void Init()
|
void Init()
|
||||||
|
@@ -215,6 +215,12 @@ protected:
|
|||||||
virtual bool DoPopupMenu(wxMenu *menu, int x, int y) wxOVERRIDE;
|
virtual bool DoPopupMenu(wxMenu *menu, int x, int y) wxOVERRIDE;
|
||||||
#endif // wxUSE_MENUS
|
#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;
|
QWidget *m_qtWindow;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -187,11 +187,16 @@ void wxFrame::SetWindowStyleFlag( long style )
|
|||||||
GetQMainWindow()->setWindowFlags(qtFlags);
|
GetQMainWindow()->setWindowFlags(qtFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* wxFrame::QtGetParentWidget() const
|
||||||
|
{
|
||||||
|
return GetQMainWindow()->centralWidget();
|
||||||
|
}
|
||||||
|
|
||||||
void wxFrame::AddChild( wxWindowBase *child )
|
void wxFrame::AddChild( wxWindowBase *child )
|
||||||
{
|
{
|
||||||
// Make sure all children are children of the central widget:
|
// Make sure all children are children of the central widget:
|
||||||
|
|
||||||
QtReparent( child->GetHandle(), GetQMainWindow()->centralWidget() );
|
QtReparent( child->GetHandle(), QtGetParentWidget() );
|
||||||
|
|
||||||
wxFrameBase::AddChild( child );
|
wxFrameBase::AddChild( child );
|
||||||
}
|
}
|
||||||
|
@@ -437,7 +437,7 @@ bool wxWindowQt::Reparent( wxWindowBase *parent )
|
|||||||
if ( !wxWindowBase::Reparent( parent ))
|
if ( !wxWindowBase::Reparent( parent ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QtReparent( GetHandle(), parent->GetHandle() );
|
QtReparent( GetHandle(), static_cast<wxWindow*>(parent)->QtGetParentWidget() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user