QWebengineView 对自定义协议的拦截处理

重新实现 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);
}

没有更多推荐了,返回首页