Fix DoMoveWindow() to take into account the frame extent
Using "move" is correct for positioning, as it takes into account the frame extent. Unfortunately, there is no corresponding API to set the frame size. So we need to compute the effective client size and use "resize". We can't use "setGeometry" for this purpose, since a widget's "geometry" excludes the frame size. We would need to adjust the position to go from frame to client coordinates. It's more straightforward to simply have Qt do it with "move". Closes https://github.com/wxWidgets/wxWidgets/pull/1349
This commit is contained in:
parent
baca938ce3
commit
be22e8fa95
@ -977,9 +977,19 @@ void wxWindowQt::DoMoveWindow(int x, int y, int width, int height)
|
||||
QWidget *qtWidget = GetHandle();
|
||||
|
||||
qtWidget->move( x, y );
|
||||
qtWidget->resize( width, height );
|
||||
}
|
||||
|
||||
// There doesn't seem to be any way to change Qt frame size directly, so
|
||||
// change the widget size, but take into account the extra margins
|
||||
// corresponding to the frame decorations.
|
||||
const QSize frameSize = qtWidget->frameSize();
|
||||
const QSize innerSize = qtWidget->geometry().size();
|
||||
const QSize frameSizeDiff = frameSize - innerSize;
|
||||
|
||||
const int clientWidth = std::max(width - frameSizeDiff.width(), 0);
|
||||
const int clientHeight = std::max(height - frameSizeDiff.height(), 0);
|
||||
|
||||
qtWidget->resize(clientWidth, clientHeight);
|
||||
}
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
void wxWindowQt::QtApplyToolTip(const wxString& text)
|
||||
|
Loading…
Reference in New Issue
Block a user