Important: Please read the Qt Code of Conduct -

Issue with Icon layout size in QToolBar on high resolution displays (retina) in Qt 5.

  • The QAction icons in QToolBar are shown with incorrect layout size and become larger when high resolution images are loaded on "retina" display. As I know high resolution images should be loaded with the same layout size as low resolution images. This issue does not exist on another Grapgics view, e.g. QWidget, QMenu etc.

    Is there such a known issue or how can I resolve it?

  • Lifetime Qt Champion


    To verify whether it's a known issue, please check the "bug report system": If you can't find anything about it, please consider opening a new report providing a compilable minimal example reproducing the problem.

  • Hello Hasmik,

    I found in qtbase/src/widgets/styles/ line 2066 (Qt 5.3.1) that it defaults to large icon size:
    case PM_ToolBarIconSize:
    ret = proxy()->pixelMetric(PM_LargeIconSize);

    But I noticed that it uses the proxy() so my own fix was to make a custom QProxyStyle that uses PM_SmallIconSize instead:
    #include <QProxyStyle>
    class MacStyle : public QProxyStyle {
    MacStyle() : QProxyStyle("Macintosh") { }

    int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget * widget = 0) const {
    if (metric == PM_ToolBarIconSize) {
    return proxy()->pixelMetric(PM_SmallIconSize);
    return QProxyStyle::pixelMetric(metric, option, widget);

    Then right before creating the QApplication you would do:
    QApplication::setStyle(new MacStyle);

Log in to reply