Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issue with Icon layout size in QToolBar on high resolution displays (retina) in Qt 5.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hasmik
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        netrom
        wrote on last edited by
        #3

        Hello Hasmik,

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

        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 {
        public:
        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);
        @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved