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. How to change icon size of the QMenu under Mac.
Forum Updated to NodeBB v4.3 + New Features

How to change icon size of the QMenu under Mac.

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.7k 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.
  • _ Offline
    _ Offline
    _Dima
    wrote on 19 Jun 2014, 16:21 last edited by
    #1

    Could you please advise how to change icon size of an item in the QMenu under Mac?

    I use QProxyStyle and overwriting its method pixelMetric. That works good under Win, but under Mac... Mac doesn't care about pixelMetric, exactly pixelMetric is not used under Mac.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Jun 2014, 20:40 last edited by
      #2

      Hi,

      AFAIK, that can't be changed in OS X

      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
      • _ Offline
        _ Offline
        _Dima
        wrote on 19 Jun 2014, 23:47 last edited by
        #3

        Hi,

        There is one interest think - if I use Qt4 library then icon size of the QMenu item is 22x22 (approximately), but if I use Qt5 then the size is 16x16. So system menu can be changed and this change is made by Qt sources…

        For example:
        TrayIcon.cpp
        @#include <assert.h>
        #include "trayicon.h"

        TrayIcon::TrayIcon(QObject parent /= 0*/)
        : QSystemTrayIcon(parent)
        , closeAction_(QIcon(":/Images/QuitIcon.png"), "", 0)
        {
        //QMenu item
        closeAction_.setText(tr("close menu"));
        trayIconMenu_.addAction(&closeAction_);
        connect( &closeAction_, SIGNAL(triggered()), this, SLOT(closeMenu()));

        //QSystemTrayIcon
        setIcon((QIcon(":/Images/trayActivated.png")));
        setContextMenu(&trayIconMenu_);
        setToolTip(tr("Test QMenu"));
        

        }

        void TrayIcon::closeMenu()
        {
        trayIconMenu_.close();
        }@

        TrayIcon.h
        @#ifndef trayicon_h_
        #define trayicon_h_

        #include <QSystemTrayIcon>
        #include <QMenu>

        class TrayIcon
        : public QSystemTrayIcon
        {
        Q_OBJECT
        Q_DISABLE_COPY(TrayIcon)
        public:
        explicit TrayIcon(QObject *parent = 0);

        signals:

        public slots:
        void closeMenu();

        private slots:

        private:

        QMenu       trayIconMenu_;
        QAction     closeAction_;
        

        };

        #endif@

        main.cpp
        @
        #include <QScopedPointer>
        #include "trayicon.h"

        QScopedPointer<TrayIcon> trayIcon(new TrayIcon());
        trayIcon_->show();
        @

        If this code is build using Qt4 or using Qt5 libraries then visual results are different:
        !http://s17.postimg.org/qt06ti93v/QT4_QT5_Context_Menu.png(Qt4 and Qt5 context menu difference)!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Jun 2014, 22:07 last edited by
          #4

          Ok, the system tray menu doesn't follow the same guidelines has a menu in the menu bar.

          Can you tell exactly what you are trying to achieve ?

          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
          • _ Offline
            _ Offline
            _Dima
            wrote on 21 Jun 2014, 12:14 last edited by
            #5

            I try to get the pop-up context menu under Mac with the icon size 22x22 px approximately. I use QMenu class from the Qt5 for this library but in the result I have icon size 16x16 px approximately. And I cannot change the icon size…Any style settings doesn't impact icon size under Mac (against Windows). And OS is not the reason of small or big size of the icon. If I use QMenu from the Qt4 then icon size is 22x22 px.

            On the same machine, under the same OS (Mac 10.9) Qt5 – 16x16px, Qt4 -22x22px, Qt5 - 16x16px, Qt4 - 22x22px.

            Now I’m investigate source code of the QMenu in the Qt4 and Qt5 libraries. I’m looking for reason of the icon size changing. Maybe size is set anywhere in the QMenu class inside.

            I cannot use 16x16 size because there is strong specification for application and it requires big size of the icon (22x22 or 20x20 px)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 23 Jun 2014, 11:35 last edited by
              #6

              AFAIK, it set in the style. However, if you have special needs, you should maybe do it another way and create your own "popup" widget

              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

              1/6

              19 Jun 2014, 16:21

              • Login

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