問題描述
在我的 Qt 應(yīng)用程序中,我在默認(rèn)瀏覽器中打開了一個 URL.之后我想再次將我的應(yīng)用程序的主窗口放在最前面.
In my Qt-application I open a URL in the default-browser. Afterwards I want to bring the main-window of my application to the front again.
我嘗試了我能找到的所有方法,但都沒有奏效.它所做的只是在任務(wù)欄(Window 7)中閃爍舉個例子:
I tried all approaches I could find but none worked. All it does is blink in the taskbar (of Window 7) Here’s an example:
this->viewer->show();
this->viewer->raise();
this->viewer->activateWindow();
*viewer 是一個指向從 QDeclarativeView 派生的 QmlApplicationViewer 的指針
*viewer is a pointer to a QmlApplicationViewer which is derived from QDeclarativeView
推薦答案
此問題特定于 Windows.如果活動窗口屬于某個進(jìn)程,則 Windows 不允許其他進(jìn)程更改活動窗口.
This problem is specific to Windows. If the active window belongs to some process, then Windows does not allow other processes to change the active Window.
(請勿嘗試以下操作:https://wiki.qt.io/Qt_project_org_faq#QWidget_::activateWindow.28.29_-_behavior_under_windows)
(Do not try the following: https://wiki.qt.io/Qt_project_org_faq#QWidget_::activateWindow.28.29_-_behavior_under_windows)
這篇關(guān)于把窗戶放在前面 ->raise(),show(),activateWindow() 不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!