PDA

View Full Version : SetTopMostWindow in QT



yyiu002
17th November 2010, 02:26
I am doing a Windows Application, what I want to achieve is while open a topmost window,when my main processing of a big configuration file starts, inform user the process is still running, after processing finished, then inform user the process has finished.

at VB6 I can call SetTopMostWindow windows API to achieve this.

But at QT, I tried a few "on top window flags", it appears only create a modal window. Not what I want.:confused:

ChrisW67
17th November 2010, 03:52
Qt::WindowStaysOnTopHint looks fairly promising. See the Window Flags Example.

yyiu002
17th November 2010, 08:32
With SetTopMostWindow API call, if a window is top most, I still can select other window's tree view control, select an item in that tree view, it leads current top most window refresh its content to what I have selected.

Can't find this ability in QT. How can I call Windows API from QT, is it possible?

ChrisW67
17th November 2010, 22:24
With SetTopMostWindow API call, if a window is top most, I still can select other window's tree view control,
Yes, Qt::WindowStaysOnTopHint does that.

select an item in that tree view,
User inputs, Qt can handle this.

it leads current top most window refresh its content to what I have selected.
Your code has to do this - there is no magic, spooky action-at-a-distance that is going to connect these widgets together (in Qt or pure Windows API code). You can use the same mechanism as you use in your other code, or you can use a signal from the tree view connected to a slot in your IAlwaysStayOnTopWindow class. The example I mentioned above does exactly the sort of thing you are asking for; updating the preview list even if the preview window is flagged Qt::WindowStaysOnTopHint. The example is in Assistant and accessible through qtdemo under Widgets.

You can access the Windows API (or any other) in any way you like from your C++ code. This has nothing to do with Qt. If you need the Windows window handle for a widget then look at the QWidget::winId() method.