PDA

View Full Version : Overlapping windows on Mac OS X



mentalmushroom
8th February 2013, 07:40
I am trying to implement a starup banner that should be shown above the main application window. It works fine on Windows, but on Mac OS X I can't get two windows shown at the same time (unless I show the banner after a some large time interval). Is there a way to ensure the window is visible on the screen before showing another one?

This is how I tried it:


#include <QApplication>

#include "mainwindow.h"
#include "banner.h"

int main(int argc, char * argv[])
{
QApplication app(argc, argv);

MainWindow mainWindow;
mainWindow.show();
//mainWindow.raise();

Banner banner;
//QTimer::singleShot(0, &banner, SLOT(show()));
//QTimer::singleShot(0, &banner, SLOT(raise()));
banner.show();

return app.exec();
}


I tried to use show, raise, delayed show/raise with zero-time interval, but nothing helps: still I see only the banner window when the application is launched, the main window becomes visible only when I click the application icon on the task bar.

Lykurg
8th February 2013, 08:12
Have you seen QSplashScreen?

mentalmushroom
8th February 2013, 08:44
Yes, I did, but that is different to what I really need. However, with QSplashScreen I also have only one window displayed: if I first show the splash screen it gets hidden by the main window when it shown, otherwise, I see only the splash screen while the main window is hidden - the behavior is wrong in both cases.

mentalmushroom
19th February 2013, 10:38
I've found the code that seems to be related to the issue I am pointing out:

#ifdef Q_WS_X11
void qt_x11_wait_for_window_manager(QWidget *widget);
#endif

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
...
window.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&window);
#endif
...
return app.exec();
}

According to the documentation, qt_x11_wait_for_window_manager blocks until the X11 window manager has shown the widget after a call to QWidget::show(). That is exactly what I need to fix the wrong behavior. Is it possible to do something similar on Mac OS X?