PDA

View Full Version : Window focus question



waynew
31st October 2009, 00:29
Researching my books and can't find an answer....

When I call a dialog from a menu selection, it appears in front of the main window, but when I call it directly from a function, it appears behind the main window.

The question is, how to insure it will appear in front of the main window when called from a function?

peirenjun
31st October 2009, 00:43
May be you can explicitly specify the z-value of your dialog

rainspider
31st October 2009, 05:18
when you create the dialog,you must give it a parent。like this:
QMessageBox msbox(mainform);

the message box will show at center of mainform.

waynew
31st October 2009, 23:11
Just for those who might experience the same problem...

The difficulty was that the dialog was actually launching before the main window because of where the call to it was - in mainwindow.cpp

After moving the call to main.cpp, after the mainwindow was shown, no problem. It shows up on top.