Good day :)
There are QToolBar
and QAction
for which the icon is installed, but the text is not installed. The size of the icon used is known to me (16 or 32) depending on the screen resolution. The created QAction
added to the QToolBar
using the addAction
method. A button is created with an icon. I need to make buttons of the same size. How does QT determine the size of the resulting button?
At the moment I think this is iconSize + indent from the icon. How to get the indent value? I will be glad to any considerations on this topic :)
Update
It turns out that to create a button of the same size as on the toolbar, should I add 2 ButtonMargin
sizes (up and down) to the content size?
int buttonMargin = QApplication::style()->pixelMetric( QStyle::PM_ButtonMargin ); int buttonSize = ButtonMargin * 2 + contentSize;
I understood correctly?
Judging by the fact that I checked QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin);
returns 6 on all platforms: (Although Padding on Windows is only 1 pixel, respectively Margin should be 3