Search code examples
c++qtinputqwebview

How to get the Value from a input field in QWebView


In Qt I have a QWebView on the screen the site in the web view has an input field, I want to get the value attribute from the input field and store it in a QString Basically what I'm asking is how can I store the value of a input field in a QString


Solution

  • From your QWebView get the QWebFrame (e.g ui->webView()->page()->currentFrame()->toHtml();) and then used QwebFrame::findAllElements or QWebFrame::findFirstElement. This will give you a QWebElement and you can use the attribute method to get the value attribute.