如何从QWebView的输入字段中获取值

How to get the Value from a input field in QWebView

本文关键字:字段 获取 输入 QWebView      更新时间:2023-10-16

在Qt我有一个QWebView在屏幕上的网站在web视图有一个输入字段,我想从输入字段中获取属性并将其存储在QString中基本上,我要问的是如何在QString

中存储输入字段的值

从你的QWebView获得QWebFrame(例如ui->webView()->page()->currentFrame()->toHtml();),然后使用QWebFrame:: findAllElements或QWebFrame::findFirstElement。这将为您提供一个QWebElement,您可以使用attribute方法来获取value属性。

你应该使用evaluateJavaScript("this.value")动态获取属性值:http://www.qtforum.org/article/34091/solved-get-html-dom-dynamic-value-via-qtwebview.html post109395