开发者

Invert colors in system tray icon upon click in Qt4?

开发者 https://www.devze.com 2023-03-18 00:33 出处:网络
Basically I want to invert the colors of my systrayicon only osx app when it is clicked (as normal on Mac apps), as is default behavior on mac apps. How would I d开发者_C百科o this now when aboutToHid

Basically I want to invert the colors of my systrayicon only osx app when it is clicked (as normal on Mac apps), as is default behavior on mac apps. How would I d开发者_C百科o this now when aboutToHide() isn’t supported on Mac?

Can I code around it somehow? Using qt 4.7.3


I hawen't written for mac but try to catch click event and manually set icon with inverted colors...

void <YourClass>::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
    if(reason==QSystemTrayIcon::Trigger)
    {
        <Your tray object>->setIcon(<Icon with inverted colors>);
    }
}

connect it to your trayIcon's signal activated()

if default behavior on mac is to invert icon colors back, you may do it with timer or something similar.


Can you set a selected state pixmap for your icon, e.g. myIcon->addPixmap(":/systray-selected.png", QIcon::Selected); ?

0

精彩评论

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