开发者

Trap click event on dock icon using Qt on Mac

开发者 https://www.devze.com 2023-01-17 15:37 出处:网络
I am trying to get dock click event on dock icon on Mac OS X. I am using Qt-Cocoa. Any help would be highly apprec开发者_StackOverflowiated.

I am trying to get dock click event on dock icon on Mac OS X. I am using Qt-Cocoa. Any help would be highly apprec开发者_StackOverflowiated.

Thanks, Rahul


I've done this for an open-source project. See the code here: https://github.com/KDAB/Charm/blob/master/Charm/MacApplicationCore.mm


In Qt-Carbon, see Qt4 Mac Dock Icon Click. It explains how to install a reopen event handler.

In Qt-Cocoa, you should get the application delegate with [[NSApplication sharedApplicaion] delegate] and add you own applicationShouldHandleReopen:hasVisibleWindows: method with class_addMethod. I have not actually tried this.


On Qt 5.9.1 you can also use a hack without any platform-specific code at all. See https://stackoverflow.com/a/46488514/8695355

0

精彩评论

暂无评论...
验证码 换一张
取 消