Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

BadgeLable related methods deprecated, how to access NSApp etc. from Qt?



  • Good afernoon,
    since I am getting deprecated warning:
    warning: 'setBadgeLabelText' is deprecated: Use NSApp.dockTile.badgeLabel
    how can I implement simple number appearing over the tile?

    So far I had a signal reporting the amount of new items and slot that simply used the now deprecated method.

    Any advice would be highly appreciated.


  • Lifetime Qt Champion

    You can take a look at the QtMacExtras module code behind the method and replicate it within your code.

    Something like:

    #import <AppKit/NSApplication.h>
    #import <AppKit/NSDockTile.h>
    
    void MyClass::showLabel(const QString& label)
    {
     [[NSApplication sharedApplication] dockTile].badgeLabel = label.toNSString();
    }
    

    The MyClass implementation should be in a file with a .mm extension and that file be added to the OBJECTIVE_SOURCES variable.


  • Lifetime Qt Champion

    Hi,

    Are you using the QtMacExtras module ?



  • @SGaist I do, yes.



  • Anyone? Anything? I am not in the rush but I'd like to at least know where to search for the answer.


  • Lifetime Qt Champion

    You can take a look at the QtMacExtras module code behind the method and replicate it within your code.

    Something like:

    #import <AppKit/NSApplication.h>
    #import <AppKit/NSDockTile.h>
    
    void MyClass::showLabel(const QString& label)
    {
     [[NSApplication sharedApplication] dockTile].badgeLabel = label.toNSString();
    }
    

    The MyClass implementation should be in a file with a .mm extension and that file be added to the OBJECTIVE_SOURCES variable.



  • Thank you, will go that way.



  • @SGaist FYI, manual now states:

    OBJECTIVE_SOURCES
    
    Specifies the names of all Objective-C/C++ source files in the project.
    
    This variable is now obsolete, Objective-C/C++ files (.m and .mm) can be added to the SOURCES variable.
    

    Same for headers. Again, thanks for your help, I think I've got this up and running :)


  • Lifetime Qt Champion

    Thanks for the info. I did that from memory.


Log in to reply