![](/img/trans.png)
[英]Setting up ImageMagick on Qt with Mac. LIBS and INCLUDEPATH
[英]Notification window in Mac. With or without Qt
Mac OS X 上的 Qt 項目。我需要在頂部顯示通知 window 而不從任何活動的應用程序中竊取焦點。
這里是小部件構造函數部分:
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 的流行即時消息應用程序 - 將其用於所有通知。
我剛剛測試了這些標志
Qt::FramelessWindowHint |Qt::WindowSystemMenuHint |Qt::WindowStaysOnTopHint
和
setFocusPolicy(Qt::NoFocus);
setAttribute(Qt::WA_ShowWithoutActivating,true);
沒有 Cocoa 或 window 標志/掩碼的碳代碼。 並且 notifyWindow 在 Windows 或 Linux 上工作。
在 mac 上試試這個:
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_AlwaysStackOnTop);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.