Question

I am facing a little annoying design problem. Not easy to give a title of my question.

I must display two windows, one over another one. The first one is a Cocoa window, the second is made with Qt. In the second window, an action is performed, but the user can choose to close this window. He must fall back on the first window.

To display my first window, which is actually a SFAuthorizationPluginView, I do:

[myview displayView];

then, to display the window made with Qt on top of first window:

QWidget* w = openMyScreen();
NSView* v = (NSView*)w->winId();
[[v window] setLevel:2003];

This works well, however there is a small delay before the second window is displayed. We can thus see for a very short time the first window.

I need that the second window stays on top of the first window, because the user can close the second window and must have access to the first window.

Any ideas on a trick how to hide the first window, just the time, the second window appears?

Thanks in advance

Was it helpful?

Solution

NSDisableScreenUpdates and NSEnableScreenUpdates (link) might be useful in this situation. The documentation says:

You typically call this function so that operations on multiple windows appear atomic to the user.

which seems to describe your situation.

A word of unrelated advice though: Don't go setting window levels willy-nilly. A window level of 2003 will likely cause the window to appear over things like the dock or even the menu bar, which would definitely be strange. You should stick to the standard levels declared in NSWindow.h unless you have good reason. NSFloatingWindowLevel might be appropriate (although I'm not sure what level the SFAuthorizationPluginView window is displayed at).

OTHER TIPS

Starting with MacOS 10.4, you can use :

[NSWindow disableScreenUpdatesUntilFlush];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top