From 4bfb3a5f018a8d63b62c8dc7b9f3b0c7136d56c2 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Tue, 4 Jun 2019 16:02:41 +0100 Subject: [PATCH] Implement wxFrame::DoSetClientSize() Resize the central widget to fit the new size. See https://github.com/wxWidgets/wxWidgets/pull/1340 --- include/wx/qt/frame.h | 1 + src/qt/frame.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/wx/qt/frame.h b/include/wx/qt/frame.h index ea515def5c..f640911a46 100644 --- a/include/wx/qt/frame.h +++ b/include/wx/qt/frame.h @@ -56,6 +56,7 @@ public: protected: virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE; + virtual void DoSetClientSize(int width, int height) wxOVERRIDE; virtual QWidget* QtGetParentWidget() const wxOVERRIDE; diff --git a/src/qt/frame.cpp b/src/qt/frame.cpp index e32bf8ec98..08f1c43f98 100644 --- a/src/qt/frame.cpp +++ b/src/qt/frame.cpp @@ -231,6 +231,19 @@ void wxFrame::DoGetClientSize(int *width, int *height) const } } +void wxFrame::DoSetClientSize(int width, int height) +{ + wxWindow::DoSetClientSize(width, height); + + int adjustedWidth, adjustedHeight; + DoGetClientSize(&adjustedWidth, &adjustedHeight); + + QWidget *centralWidget = GetQMainWindow()->centralWidget(); + QRect geometry = centralWidget->geometry(); + geometry.setSize(QSize(adjustedWidth, adjustedHeight)); + centralWidget->setGeometry(geometry); +} + QMainWindow *wxFrame::GetQMainWindow() const { return static_cast(m_qtWindow);