Qt WebKit and HTML5 geolocation

筅森魡賤 提交于 2019-12-06 00:42:10

You need to subclass QWebPage and make a signal handler for the QWebPage::featurePermissionRequested(QWebFrame*, QWebPage::Feature) signal.

Here is a reference implementation:

class WebPage : public QWebPage
{
    Q_OBJECT

    public:
        WebPage(QObject* parent = 0) :
            QWebPage(parent)
        {
            connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), SLOT(permissionRequested(QWebFrame*, QWebPage::Feature)));
        }

        virtual ~WebPage()
        {
        }

    private slots:
        void permissionRequested(QWebFrame* frame, QWebPage::Feature feature)
        {
            setFeaturePermission(frame, feature, PermissionGrantedByUser);
        }
};

Use QWebView::setPage() with an instance of your newly created subclass to make QtWebKit use your QWebPage implementation.

In case you need more help, have a look at the QtMiniBrowser which is part of the WebKit.org repository. The source code is available from here http://trac.webkit.org/browser/trunk/Tools/QtTestBrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!