我正在使用QDesktopServices::openUrl(url); 打开网址。
如何通过用户定义的代码关闭它?
I am using QDesktopServices::openUrl(url); to open a url.
How can I close that through user defined code?
最满意答案
您正在浏览器窗口中打开您的URL,在该窗口中,用户代码没有任何控制权。 所以基本上你无法关闭浏览器。
解决方法可能是您编写脚本并检测是否在系统上打开了浏览器,如果是,您可以通过终止该过程来关闭浏览器。 但我不建议使用此方法,因为它在某些平台上存在许多安全性和标准合规性问题。
编辑:
您不需要创建自己的浏览器,只需使用Qt Webkit在您自己的窗口中呈现打开的URL。
You are opening your URL in a browser window, on which user code doesn't have any control. So basically you cannot close the browser.
A workaround could be that you write a script and detect if a browser is opened on the system, if yes you can close the browser by terminating that process. But I do not recommend this method as it has many security and standard compliance issues on some platforms.
EDIT:
You do not need to create your own browser, just use Qt Webkit to render the opened URL within your own window.
更多推荐
发布评论