qwebview保存html,qt - Append html to a QWebView? - Stack Overflow

I've got a webView setup to display chat message.

I'm initiating it like this:

ui->webView->setHtml("

friday
Bill

Hello

");

(The above code is all on one line in QT, I just hit enter to make it easier to read here)

Now I'm trying to figure out how to append div's it to in the form of new chat messages.

Tried to append like this:

QString html = "

Test test
";

QString js = QString("document.execCommand('InsertHTML',false,'%1');").arg(html);

ui->webView->page()->mainFrame()->evaluateJavaScript(js);

Switching out the date works fine, I do that like this:

// Switches out the date

QWebFrame *pSource = ui->webView->page()->mainFrame();

QWebElement dateDiv = pSource->findFirstElement("#date");

dateDiv.replace("

sunday
");

However inserting new div's is what i cannot get to work.

Any ideas what I'm doing wrong?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值