QStyleOptionButton opt; int iconWidth = opt.rect.width() / 2; int iconHeight = opt.rect.height() / 2; int iconX = opt.rect.x() + opt.rect.width() - pixelMetric(QStyle::PM_ButtonIconSize) - iconWidth - pixelMetric(QStyle::PM_ButtonShiftHorizontal); int iconY = opt.rect.y() + (opt.rect.height() - pixelMetric(QStyle::PM_ButtonIconSize)) / 2;
QStyleOptionTitleBar opt; int titleHeight = pixelMetric(QStyle::PM_TitleBarHeight); int minHeight = qMax(opt.minimumSize.height(), titleHeight);This code calculates the minimum height of a title bar widget. It takes into account the current height of the title bar and the minimum height allowed by the widget. These examples are based on the Qt framework, which is commonly used in the development of cross-platform desktop applications. Therefore, the package library for the QStyle pixelMetric function is likely to be the Qt library.