Important: Please read the Qt Code of Conduct -

[Solved] General questions about QWebView and QWebElement

  • So, I have a QWebView and I load a web page inside it.

    Then, I get the document:

    @QWebElement document = webView->page()->mainFrame()->documentElement();@

    Question 1: When I edit the 'document' does it update automatically inside my QWebView ?

    This is how I edit my document (simplified code, it misses crash checks etc):

    @QWebElementCollection collection = document.findAll(search_for);
    cur_element.setAttribute(attribute, value);

    Question 2: When an element has focus (which in my case, it will be an element tagged "input"), how can I simulate an Return (Enter) key event into my QWebView so as not to search for the submit button and generalize more the submit process? (e.g. I don't want to do this:

    Question 3: When a form is submitted (hopefully by simulating a key enter press event (or if a QWebElement tagged "button" is clicked) does my QWebView loads again? Because I want to know whether the loadFinished() signal is emitted again.

  • I solved all of my issues, here are the answers:

    Question 1:


    Question 2:

    webView->event(new QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier));

    Question 3:


Log in to reply