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.
-
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. -
Hi,
Are you using the QtMacExtras module ?
-
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. -
@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 :)
-
Thanks for the info. I did that from memory.