Adjust button size to match parent TitleBar height

Updated the Button::sizeHint() method to use the height of the parent TitleBar as the button size, defaulting to 24 if unavailable. This change ensures button sizing is consistent with the TitleBar's height.
This commit is contained in:
Mikhail Shashin
2025-11-28 01:00:21 +03:00
parent 3e60c9ce2c
commit 549df2cbe2
@@ -95,13 +95,10 @@ void Button::paintEvent(QPaintEvent *)
QSize Button::sizeHint() const
{
// Pass an opt so it scales against the logical dpi of the correct screen (since Qt 5.14) even
// if the HDPI Qt::AA_ attributes are off.
QStyleOption opt;
opt.initFrom(this);
const int m = style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, this);
return QSize(m, m);
// Используем высоту родителя (TitleBar) для размера кнопки
int h = parentWidget() ? parentWidget()->height() : 24;
if (h <= 0) h = 24;
return QSize(h, h);
}
bool Button::event(QEvent *ev)