C++ Win toast/balloon通知最近在使用Qt的windows 10上停止工作
在我看来,windows balloon消息几周前在windows 10上完全停止工作。2019年8月,以下基于Qt的代码可用于在windows action center中发布通知,并让toast弹出该通知:C++ Win toast/balloon通知最近在使用Qt的windows 10上停止工作,c++,qt,toast,notification-area,qsystemtrayicon,C++,Qt,Toast,Notification Area,Qsystemtrayicon,在我看来,windows balloon消息几周前在windows 10上完全停止工作。2019年8月,以下基于Qt的代码可用于在windows action center中发布通知,并让toast弹出该通知: #include <QApplication> #include <QSystemTrayIcon> int main(int argc, char **argv) { QApplication app( argc, argv ); //cre
#include <QApplication>
#include <QSystemTrayIcon>
int main(int argc, char **argv)
{
QApplication app( argc, argv );
//create a notification icon, and post a test notification
QSystemTrayIcon *trayTest = new QSystemTrayIcon();
trayTest->setIcon( QIcon( "path-to-some-icon-resource" ) );
trayTest->show();
trayTest->showMessage( "Hello", "world" );
return app.exec();
}
Shell_NotifyIcon用于不同版本的Qt,用于showMessage的windows实现。我验证了在Qt5.7下调用QSystemTrayIcon::showMessage时调用了Shell_NotifyIcon,如果没有发生错误,它会返回1,并且没有显示任何通知。使用“焦点辅助”和“通知和操作”设置没有效果
最近是否有windows更新修改了windows通知的行为?是否只能使用一些新的本机windows 10 API发布通知?我找不到任何关于windows更新和通知不再显示的内容
bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, uint uSecs)
{
NOTIFYICONDATA tnd;
memset(&tnd, 0, notifyIconSize);
qStringToLimitedWCharArray(message, tnd.szInfo, 256);
qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64);
tnd.uID = q_uNOTIFYICONID;
tnd.dwInfoFlags = iconFlag(type);
tnd.cbSize = notifyIconSize;
tnd.hWnd = m_hwnd;
tnd.uTimeout = uSecs;
tnd.uFlags = NIF_INFO | NIF_SHOWTIP;
return Shell_NotifyIcon(NIM_MODIFY, &tnd);
}