Mac OS X上的Qt项目.我需要在顶部显示通知窗口,而不会从任何活动应用程序中窃取焦点.
这里的小部件构造函数部分:
setWindowFlags(
    Qt::FramelessWindowHint |
    Qt::WindowSystemMenuHint |
    Qt::Tool |
    Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_TranslucentBackground);
Qt :: WA_ShowWithoutActivating不会影响任何事情.
有没有办法做到这一点?我准备在那里实施原生碳/可可溶液,但Qt是首选.或许我在Mac哲学中错了,我应该以另一种方式通知用户?
更新 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中相同的好行为:
| 归档时间: | 
 | 
| 查看次数: | 3651 次 | 
| 最近记录: |