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. Label in Mac dock icon [Solved]
Forum Updated to NodeBB v4.3 + New Features

Label in Mac dock icon [Solved]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k 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.
  • J Offline
    J Offline
    janfaroe
    wrote on last edited by
    #1

    Hi all,

    I'm not sure whether my previous research on this was for Java Swing or Qt, but I haven't been able to find any usable results right now:

    Is it possible to add a (1-2 digit) label to a dock icon on Mac OS with Qt? I know it's possible using pure Obj. C, but is there a specific interface in Qt that does just that?

    Thanks in advance.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      janfaroe
      wrote on last edited by
      #2

      The silence tells everything I guess. Oh well. Even though my objective C skills are below zero, I managed to put together a simple wrapper class after a bit of googling and experimentation:

      DockIconLabel.h:

      @#ifndef DOCKICONLABEL_H
      #define DOCKICONLABEL_H

      #include <QString>

      class DockIconLabel
      {
      public:
      static void setValue(const QString &val);
      };

      #endif // DOCKICONLABEL_H@

      DockIconLabel.mm:

      @#include "DockIconLabel.h"
      #import "Foundation/NSAutoreleasePool.h"
      #import "AppKit/NSApplication.h"

      void DockIconLabel::setValue(const QString &val)
      {
      const QByteArray utf8 = val.toUtf8();
      const char* cString = utf8.constData();
      [[[NSApplication sharedApplication] dockTile] setBadgeLabel:[[NSString alloc] initWithUTF8String:cString]];
      }

      @

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

        Na, you were just quicker to find the solution :)

        Thanks for sharing !

        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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi again,

          There are now helper functions in qtmacextras to do that

          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
          • J Offline
            J Offline
            janfaroe
            wrote on last edited by
            #5

            Sounds good, thanks for info!

            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