重新实现 TNWebEnginePage 的 acceptNavigationRequest 函数:
// If the function returns true, the navigation request is accepted and url is loaded.
bool MyWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
if (isMainFrame)
{
QString resUrl = url.toString(QUrl::DecodeReserved);
if (resUrl.startsWith(QStringLiteral("myprotocol://"), Qt::CaseInsensitive))
{
//handleMyProtocol(resUrl);
return false;
}
}
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}
重写TNWebEnginePage导航请求

本文介绍了一种重写TNWebEnginePage类中的acceptNavigationRequest函数的方法,该函数用于控制网页导航请求的接受与否。当遇到特定协议(如'myprotocol://')时,函数会阻止导航并返回false。
1117

被折叠的 条评论
为什么被折叠?



