如何在输入字段中获取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"); } }
}
如果我设置属性,比它的工作,但我想抓住用户输入,任何想法?
您可以使用QWebElement :: evaluateJavaScript().
qDebug() << "element.attribute value:" << element.evaluateJavaScript("this.value").toString();