Mac的通知窗口.有或没有Qt
Notification window in Mac. With or without Qt
Mac OS x上的Qt项目。我需要在顶部显示通知窗口,而不会从任何活动应用程序窃取焦点。
这里是小部件构造函数部分:
setWindowFlags(
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::Tool |
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_TranslucentBackground);
Qt::WA_ShowWithoutActivating不影响任何东西
有办法吗?我准备在那里实现原生Carbon/Cocoa解决方案,但Qt是首选。或者我在Mac哲学上是错的,我应该用另一种方式通知用户?
Update Growl不支持编辑器行通知,是吗?
我做到了!
#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
}
我们得到了几乎和Windows一样好的行为:
- 它并没有抢走秀上的焦点。(网上搜索两周)
- 那里的控件处理第一次用户点击,而其他窗口需要一个额外的点击来激活。
- 当窗口被激活时,同一应用程序的其他窗口不会冒泡到前面。
- 还有一个小问题,但至少有一个简单的解决方案。或者甚至可以离开。
,
你听说过咆哮吗?Growl是一个非常令人印象深刻的通知应用程序,你可以捆绑和使用你的应用程序。Adium——一个流行的OS X即时通讯应用——使用它来发送所有通知。
http://growl.info/您可以实现Growl。http://growl.info/documentation/developer/
在mac上试试:
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_AlwaysStackOnTop);
我刚刚测试了这些标志
Qt::FramelessWindowHint |Qt::WindowSystemMenuHint |Qt::WindowStaysOnTopHint
和
setFocusPolicy(Qt::NoFocus);
setAttribute(Qt::WA_ShowWithoutActivating,true);
没有Cocoa或Carbon代码的窗口标志/掩码。
相关文章:
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 在qt窗口中具有图像,而无需将图像文件本身作为源
- QT 窗口模式禁用菜单中的操作
- 每次qt窗口获得焦点时调用函数
- 恢复Qt窗口大小和位置问题
- 尝试使用 CPP 在一个 Qt 窗口中显示多个 png 文件
- 如何在单击QT窗口时将键盘控件返回到QT窗口
- 在单个进程中使Qt顶级窗口被其他非Qt窗口"owned"
- 将QT窗口强加于特定的屏幕
- 向Qt窗口发布消息不会生效
- 错误编译QT创建者 / QT窗口小部件示例
- 在Qt窗口中的一小部分中查看图像
- 创建一个没有父级的新Qt窗口是否也会创建一个新线程
- Qt 窗口包含提升线程标头失败
- 阻止Qt窗口在挂钩应用程序中关闭,Eventfilter什么也不做
- Qt窗口不会使用其他类的"this->close()"关闭
- 在Qt窗口小部件/QWindow上显示供过于求窗口
- Qt::WindowStaysOnBottom提示和无框标志使不要将我的Qt窗口保留在所有窗口的底部
- Qt:窗口函数是未解析的外部符号
- 如何将新的Qt窗口与现有的X应用程序集成