我们如何通过程序关闭打开的Url?(How can we close the opened Url through program?)

编程入门 行业动态 更新时间:2024-10-28 02:30:13
我们如何通过程序关闭打开的Url?(How can we close the opened Url through program?)

我正在使用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.

更多推荐

本文发布于:2023-08-07 22:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466369.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   Url   close   opened   program

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!