Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QToolButton icon scaled down on Windows - why?
I'm setting icons on a series of QToolButtons. The icons are all 32x32 px, and I'm using QToolButtons::setIconSize(QSize(32, 32)) to "force" the icon sizes. This works great in Mac OS, however, on Windows, the icons are visibly scaled down. Any idea what might cause this/how to prevent?
Could you check whether both returns the same iconSize ?
Both places return QSize(32, 32) , which makes sense, since I'm setting the size with setIconSize(QSize(32, 32)) .
Edit: I should perhaps mention that the buttons are added to the toolbar portion of a window, and then grouped with a QButtonGroup.
bq. Edit: I should perhaps mention that the buttons are added to the toolbar portion of a window, and then grouped with a QButtonGroup
I guess the tool bar's icon size is applied just to its children if applicable, and is N/A for the button group(it hasn't an iconSize to propagate to its children on) ... so you need to set the icon size expplicitely to each tool button and it would work
As stated two times before, I am setting the icon sizes explicitly with setIconSize(QSize(32, 32)) ;-)
Edit: Setting the icon sizes after adding to the toolbar has no effect.
Also, this works ok on Mac OS. Only not on WIndows.
ah, ok ... I have thought you setIconSize by tool bar
but anyway I tested this and it works:
QToolButton *button1 = new QToolButton;
QToolButton *button2 = new QToolButton;
QToolButton *button3 = new QToolButton;
QGroupBox *groupBox = new QGroupBox();
QHBoxLayout *hbox = new QHBoxLayout;
hbox->setContentsMargins(0, 0, 0, 0);
NicuPopescu: And the icon is indeed shown as 32x32 and is not scaled down? What Qt version are you using? OS? I'm on 5.2 beta.
I tested with qt 5.1.1 mingw and qt 5.2.0 beta VS 2010 on Windows XP ... on both it's working fine
Bingo - the QGroupBox did the trick. Thanks!
I'm not sure why it does a difference though. As you, I am adding the buttons to a QToolBar.
Sounds like it could be a Windows specific bug. Did you check on the "bug report system":http://bugreports.qt-project.org whether something like that was reported ?
I was not sure whether it was/is me that was on the wrong side of the street. A search for "windows qtoolbutton icon size" does not give any results.
Not necessarily, there can be regressions/subtle differences between platforms.
Then you can open a new report with a minimal compilable example that helps reproduce the behavior. Providing the link here would be a plus
Yes, a bug report seems appropriate. Looking closer, enclosing the QButtons in QGroupBox changes the look of the buttons. This is of course notable on the Mac as well.
Seems like it's a problem on Windows 7 as well. Added this to the bug report. I could sort of accept that this was a problem on XP only, but not across the whole Windows line as it seems. I'm wondering why no-one else notices things like this? Given the amount of bug reports from me alone regarding widgets (especially on the Mac), I'm gonna hit an email to Digia, having ranted basically everywhere else about the state of Widgets and desktop platforms to no avail. This is soooo frustrating!