From Qt online help:
void QWebElement::setPlainText ( const QString & text )Replaces the existing content of this
element with text. This is equivalent
to setting the HTML innerText
property.
My code:
QWebElement login = doc.findFirst("input[name=\"login\"]");
login.setPlainText("alibaba");
qDebug() << login.toPlainText();
And the output is “”.
Why I don’t see new value of login element?
The problem is the
inputhtml element doesn’t have the closing tag so there’s no sense in using methods that operate (set some content) in a space between the opening and the closing tag…Besides, it’s
valueattribute that should be set and not the content of theinputelement 🙂