0

QWebEngineView has signal void loadStarted(). It emits this signal when it received from QWebEnginePage. QWebEnginePage overrides this function from QWebEnginePagePrivate, where it is void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false), but in QWebEnginePage class argument provisionalUrl marked as Q_UNUSED(), but I want to know its value. How can I do it?

Sacha_D
  • 68
  • 1
  • 10
  • Or How via QWebEngineView get parameters of form's method "POST" or "GET" and hyperlink's url clicked on displayed web page? – Sacha_D Nov 01 '17 at 14:57
  • What about the result of calling QWebEnginePage::url(), does that not tell you which URL/page has been loaded/viewed? Also take a look at QWebEnginePage::requestedUrl() - The URL requested to loaded by the frame currently viewed. The URL may differ from the one returned by url() if a DNS resolution or a redirection occurs. – ManuelH Nov 02 '17 at 08:23
  • I tried QWebEnginePage::requestedUrl() - it returns address of already loaded page. I need to intercept on page buttons presses and links clicking. To know what link was clicked, generate new web-page and navigate user on it. – Sacha_D Nov 02 '17 at 12:40

1 Answers1

0

If you have to intercept navigation requests and filter them by navigation type, the best you can do is to override QWebEnginePage::acceptNavigationRequest() virtual function.

https://doc.qt.io/qt-5/qwebenginepage.html#acceptNavigationRequest

class NavigationRequestOverride : public QWebEnginePage
{
public:
    NavigationRequestOverride(QObject* parent) : QWebEnginePage(parent) {}
protected:
    virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
    {
       // Here goes your logic
    }
};
Sz. David
  • 111
  • 1
  • 6