QtWebkit和QWebElement - 获取用户输入?

Ken*_*nni 4 qt input qtwebkit qwebelement

如何在输入字段中获取userinput?

QObject::connect( webView, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()) );
void slotLoadStarted()
{
   QWebFrame *frame = webView->page()->currentFrame();

   if (frame!=NULL)
   {
      QWebElementCollection collection = frame->findAllElements("input[name=email]");

      foreach (QWebElement element, collection)
      {
        qDebug() << "element.toOuterXml" << element.toOuterXml();
        qDebug() << "element.attribute value:" << element.attribute("value");
      }       
   }
Run Code Online (Sandbox Code Playgroud)

}

如果我设置属性,比它的工作,但我想抓住用户输入,任何想法?

Jak*_*rek 6

您可以使用QWebElement :: evaluateJavaScript().

qDebug() << "element.attribute value:" << element.evaluateJavaScript("this.value").toString();
Run Code Online (Sandbox Code Playgroud)