Qt有获取系统默认浏览器的接口(interface)吗?
我想在浏览器中显式打开一个 file://
url 而不是系统的默认应用程序,所以 QDesktopServices::openUrl不是因为
If the URL is a reference to a local file (i.e., the URL scheme is "file") then it will be opened with a suitable application instead of a Web browser.
最佳答案
对于您的特定应用程序,您应该使用 Qt 附带的 Web 引擎:
QWebEngineView *view = new QWebEngineView{parent};
view->load(QUrl{"file://...."});
view->setWindowFlags(Qt::Window);
view->setAttribute(Qt::WA_DeleteOnClose);
view->show();
如果html足够简单,使用文本浏览器:
QTextBrowser *view = new QTextBrowser{parent};
view->setSource(Qurl{"file://...."});
view->setWindowFlags(Qt::Window);
view->setAttribute(Qt::WA_DeleteOnClose);
view->show();
https://stackoverflow.com/questions/38954534/