C++ Mac中的通知窗口。有无Qt
Mac OS X上的Qt项目。我需要在顶部显示通知窗口,而不会从任何活动应用程序中窃取焦点 这里是小部件构造函数部分:C++ Mac中的通知窗口。有无Qt,c++,qt,macos,C++,Qt,Macos,Mac OS X上的Qt项目。我需要在顶部显示通知窗口,而不会从任何活动应用程序中窃取焦点 这里是小部件构造函数部分: setWindowFlags( Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::Tool | Qt::WindowStaysOnTopHint ); setAttribute(Qt::WA_TranslucentBackground); 不会影响任何事情 有办法吗?我已经准备好在
setWindowFlags(
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::Tool |
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_TranslucentBackground);
不会影响任何事情
有办法吗?我已经准备好在那里实施原生碳/可可解决方案,但Qt是首选。
或者也许我的Mac理念是错误的,我应该以另一种方式通知用户
更新Growl在其通知中不支持编辑器行,是吗?Pavel
你听说过咆哮吗?Growl是一款令人印象深刻的通知应用程序,您可以将其捆绑并与应用程序一起使用。Adium是一款流行的OSX即时消息应用程序,用于所有通知
您可以实现咆哮 我做到了
#ifdef Q_OS_MAC
#include <Carbon/Carbon.h>
#endif
NotifyWindow::NotifyWindow() : QWidget(0 /* This zero is the first point */) {
setWindowFlags(
#ifdef Q_OS_MAC
Qt::SubWindow | // This type flag is the second point
#else
Qt::Tool |
#endif
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_TranslucentBackground);
// And this conditional block is the third point
#ifdef Q_OS_MAC
winId(); // This call creates the OS window ID itself.
// qt_mac_window_for() doesn't
int setAttr[] = {
kHIWindowBitDoesNotHide, // Shows window even when app is hidden
kHIWindowBitDoesNotCycle, // Not sure if required, but not bad
kHIWindowBitNoShadow, // Keep this if you have your own design
// with cross-platform drawn shadows
0 };
int clearAttr[] = { 0 };
HIWindowChangeAttributes(qt_mac_window_for(this), setAttr, clearAttr);
#endif
}
#ifdef Q#u OS#u MAC
#包括
#恩迪夫
NotifyWindow::NotifyWindow():QWidget(0/*此零是第一个点*/){
设置窗口标志(
#ifdef Q_OS_MAC
Qt::SubWindow |//此类型标志是第二点
#否则
Qt::工具|
#恩迪夫
Qt::FramelessWindowHint|
Qt::WindowSystemMenuHint|
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_半透明背景);
//这个条件块是第三点
#ifdef Q_OS_MAC
winId();//此调用创建操作系统窗口ID本身。
//qt_mac_window_for()没有
int setAttr[]={
kHIWindowBitDoesNotHide,//即使应用程序被隐藏,也会显示窗口
khiwindowbitdootcycle,//不确定是否需要,但还不错
kHIWindowBitNoShadow,//如果你有自己的设计,就保留这个
//具有跨平台绘制的阴影
0 };
int clearatr[]={0};
HIWindowChangeAttributes(qt_mac_window_for(this)、setAttr、clearAttr);
#恩迪夫
}
我们获得了与Windows中几乎相同的良好行为:
- 它并没有把注意力转移到节目上。(在互联网上搜索两周)
- 那里的控件处理用户的第一次单击,而其他窗口需要额外的单击才能激活
- 当激活该窗口时,同一应用程序的其他窗口不会向前冒泡
- 这是一个小问题,但至少有一个简单的解决方法。甚至可能被留下
Qt::FramelessWindowHint |Qt::WindowSystemMenuHint |Qt::WindowStaysOnTopHint
及
窗户标志/遮罩无可可或碳代码。
notifyWindow的工作原理与Windows或Linux类似。在mac上试试:
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_AlwaysStackOnTop);
如果是一个选择,我推荐它。它已成为OS X上通知的事实标准。例如@baqlineedit
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_AlwaysStackOnTop);