QtWebKit、QWebElement::setPlainText() 问题

发布于 2024-07-29 08:37:32 字数 535 浏览 15 评论 0原文

来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-08-05 08:37:32

问题是 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 the input element :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文