PDA

View Full Version : Calling a slot/function immediately after the a Window is shown



momesana
14th February 2009, 19:21
Hi,
Can you guys tell me how to call a slot just after a window is being shown (must be complete and visible) to the user? I tried overriding setVisible() or handling showEvent() but they are both called before the window is fully shown not afterwards.I actually want an intro animation to begin immediately after the window is shown to the user. My current hack involves using showEvent to trigger a singleShot timer that in turn starts the animation 500 ms after the showEvent is handled. I am not satisfied with the result though. When the window is created in under 500ms, then the animation will lag behind and when it takes longer the animation is already finished when the window is visible to the user. Very ugly! Any solutions?

Thanks in advance
momesana

talk2amulya
14th February 2009, 19:42
There are two kinds of show events: show events caused by the window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous()) show events are sent just after the window system shows the window; they are also sent when a top-level window is redisplayed after being iconified. Internal show events are delivered just before the widget becomes visible.

so i think u need to check for QEvent::spontaneous()

momesana
14th February 2009, 20:08
There are two kinds of show events: show events caused by the window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous()) show events are sent just after the window system shows the window; they are also sent when a top-level window is redisplayed after being iconified. Internal show events are delivered just before the widget becomes visible. (http://doc.trolltech.com/latest/there%20are%20two%20kinds%20of%20show%20events:%20 show%20events%20caused%20by%20the%20window%20syste m%20%28spontaneous%29,%20and%20internal%20show%20e vents.%20spontaneous%20%28qevent.html#spontaneous% 20show%20events%20are%20sent%20just%20after%20the% 20window%20system%20shows%20the%20window;%20they%2 0are%20also%20sent%20when%20a%20top-level%20window%20is%20redisplayed%20after%20being% 20iconified.%20Internal%20show%20events%20are%20de livered%20just%20before%20the%20widget%20becomes%2 0visible.)
so i think u need to check for QEvent::spontaneous()

Yep I've read the documentation. What I am really trying to do is to animate the icons in kickoff's tabbar in KDE4. When I click on the start-menu icon Kickoff is made visible. The tabbar is a child of the window so actually I am checking the tabbar's showEvent not the one belonging to the window. Thus it's an internal show event, and to be honest I don't want to modify other classes except the TabBar. Any other ideas :-( ?