PDA

View Full Version : window on top of an application



siddhu
15th December 2009, 16:35
Hello experts,

I want to pop up a window ( may be part of same application or as a different application/process ), which stays always on top of the our application's main window. The window that pops up is playing a video. When video window is on top we should be able to interact with the main window(like a modeless dialog). During the the interaction with the main window it might happen that a modal dialog pops up. When a modal dialog pops up user should be able to interact with video window ( lets say pause the video) and also with the modal dialog ( close or press OK on the dialog).
Also user may switch to other applications running on the machine. whatever happens , whenever our application is active , the video window should be on top of it and user should be able to interact with the main window and any other modal dialog that appears and also with the video window.
Also user should be able to switch to other applications ( MS-Word,excel etc) with normal behavior ( no video window on top of other applications ).

Please suggest how can I do that?

Thanks
Siddharth

spirit
15th December 2009, 16:49
take a look at QWidget::setWindowFlags + Qt::WindowStaysOnTopHint.

siddhu
15th December 2009, 17:32
Qt::WindowStaysOnTopHint brings the window on top but you can not do anything on window ( e.g. press buttons on that window), if there is another modal dialog open and unless you close the modal dialog.

spirit
15th December 2009, 17:41
if a widget, for which Qt::WindowStaysOnTopHint has been set, is not a modal then everything should work.

siddhu
15th December 2009, 18:15
window which is on top is not modal, and lets say we have a push button on this window.
and if there is another modal dialog pops up then we can not press the push button on the window unless we close the modal dialog, even though Qt::WindowStaysOnTopHint is set for the window.

spirit
15th December 2009, 18:26
probably I don't understand what you need.
take a look at $QTDIR/examples/widgets/windowflags example.
make a preview window as always on top and try to play with controls of settings window.

siddhu
15th December 2009, 18:42
Ok Lets say we have a main window which is derived from QMainWindow. Now when the application is running, due to some event a modeless window appears. this modeless window has a push button. Since this is modeless window user can interact with mainwindow. So far so good.
Lets say user does something on a main window ( may be pressed any button or invoked any context menu ) due to which a modal dialog appears. Now user wants to press the button on modeless window. he can not do it unless he closes the modal dialog.
I want that user should be able to press the button on modeless window, even if a modal dialog is active.
I saw the windowsflags example but i could not get what i'm looking for.

spirit
15th December 2009, 18:48
I'm afraid that you should not use modal dialogs in this case.

siddhu
15th December 2009, 19:09
Hello spirit,

Thanks for your answer!!

Basically I can not avoid or get rid of modal dialogs from the application.
Can I make this modeless dialog as part of different application in such a way that it remains on top of my main application, and this way it will not be affected by modal dialogs in the main application.

If I can do this then I guess I would need to synchronize the windows of two different apllications.
Is there is any way in QT to handle the windows of two different applications?

Thanks again!!

nish
16th December 2009, 14:53
dont pass the parent to your modeless window... set the parent 0 .. now hopefully the other model dialogs should not block your parentless window..