How to set badge notification for Qt on Mac

1.8k Views Asked by At

I want to set badge (notification number) on mac application using Qt,

I also try QApplication::setWindowIcon() but it's only change the icon on window and dialog, not the icon on dock. Is there anyway to set badge using Qt ? Can I call cocoa methods from Qt to set badge ?

Thank you

2

There are 2 best solutions below

1
On

If you're using Qt 5.3, you're in luck! Badge notification numbers are supported in the Qt Mac Extras package. Specifically, see QtMac::setApplicationIconBadgeNumber()

0
On

The dock icon is provided by whatever .icns file your app uses, which is reflected by the icon in Finder, you can set it with ICON = /path/to/your/icon.icns in your .pro file. For setting notifications for your app you have to jump into the Objective-C++ bridge, but there's an answer here that shows how to do it: Mac OS UserNotificationCenter in Qt.