QtWebKit、QWebElement::setPlainText() 问题
来自 Qt 在线帮助:
void QWebElement::setPlainText ( const QString & text )
替换此内容的现有内容 带有文本的元素。 这相当于 设置 HTML insideText 属性。
我的代码:
QWebElement login = doc.findFirst("input[name=\"login\"]");
login.setPlainText("alibaba");
qDebug() << login.toPlainText();
输出是“”。
为什么我看不到登录元素的新值?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是
input
html 元素没有结束标记,因此使用在开始和结束标记之间的空格中操作(设置一些内容)的方法是没有意义的...此外,应该设置的是
value
attribute 而不是input
元素的内容:)The problem is the
input
html 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
value
attribute that should be set and not the content of theinput
element :)