[Qt-interest] a Notification Widget under OSX

Bartosh Wroblevksy bartosh at live.com
Wed Feb 3 13:48:44 CET 2010


Hi there,
In short, I believe you are screwed here. It's sort of a catch 22 situation. you want to have your cake and eat it too: You need the window to be active to catch the enterEvent, you need it to be inactive because you don't want to interrupt what the user is doing. There is no obvious solution.When the window is inactive, AFAIK (check with others to be sure) QApplication::event or QApplication::macEventFilter(EventHandlerCallRef caller, EventRef event) is just not called.

If I had to do a notification on Mac such as Growl, I guess, when it would come time to display my notification window, I would do something like this 
	    notificationWidget* aWidget= new notificationWidget();            aWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);            aWidget->show();
The notification widget does not in this case grab the focus when it's shown. I have not played with and the flag or absence of setAttribute(Qt::WA_ShowWithoutActivating). However all it seems to be doing on Mac OSX is voiding the effect of activateWindow()(AFAICT)
True the QWidget::EnterEvent is not called when the mouse hovers inside the widget because the window is inactive. But it does get called once you click on the widget. Growl seems to behave this way or does it change appearance when the mouse just hovers over it?
Also want to note that if the application appears in the dock, I would add	     	    QApplication::alert(aWidget,10000); 
Which makes the little application icon jump in the dock.

Bartosh


From: MGuillon at movea.com
To: qt-interest at trolltech.com
Date: Tue, 2 Feb 2010 17:12:46 +0100
Subject: [Qt-interest] a Notification Widget under OSX



Hi, I need a little help with a specific use of  QMainWindow.My aim is to create a Notification System similar to Growl for my application. I have it running very well under Window. I simply create, from my QT application(which is a simple trayicon and a core),  a QMainWindow with no parent, Then I set  setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::SubWindow);setAttribute(Qt::WA_ShowWithoutActivating); Then When I show the notification I do Show();Raise(); It works very very well on windows because the notification doesn’t take the focus so it doesn’t stop what I am doing. And the notif is still raised so I get enter and leave event so I can do pretty things. The problem appears on OSX, I cannot find a way to reproduce that behavior. With such a code I get no mouse enter or leave event because the window is not really raised (because of Qt::WA_ShowWithoutActivating I presume)Now If I raise the notification on OSX, the I get the events but the notification window gets the focus and so it stops what I am working on. If anyone sees a way to reproduce the behavior I have on windows under OSX, It would be quite amazing Thanks in advance 		 	   		  
_________________________________________________________________
Introducing Windows® phone.
http://go.microsoft.com/?linkid=9708122
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100203/e0093f3b/attachment.html 


More information about the Qt-interest-old mailing list