嗨,有人可以帮我找到文档(我不确定要查找什么)能够使用Qt Webkit更改WebPage上的输入文本框内的文本 - 我想基本上创建一个功能,以便人们可以记住他们在网页上的输入并保存为预设..单击预设后 - 自动填写.
我相信你可以使用QWebFrame对象来访问加载后页面的web元素集合; QWebFrame可以通过QWebView的page()方法获得.有关详细信息,请参阅下面的示例; 它加载谷歌网页并将值插入搜索文本框:
...
// connect the load finished signal of the webview
QWebView::connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(on_pageLoad_finished(bool)));
// load a webpage
QUrl url("http://www.google.com/");
ui->webView->load(url);
...
Run Code Online (Sandbox Code Playgroud)
on_pageLoad_finished信号实现:
void MainWindow::on_pageLoad_finished(bool ok)
{
if (ok)
{
QWebFrame* frame = ui->webView->page()->currentFrame();
if (frame!=NULL)
{
// get collection of the input web elements with name set to "q"
// this function was introduced in Qt 4.6.
QWebElementCollection collection = frame->findAllElements("input[name=q]");
foreach (QWebElement element, collection)
element.setAttribute("value", "qt webkit autocomplete an input");
}
}
}
Run Code Online (Sandbox Code Playgroud)
希望这有帮助,问候
| 归档时间: |
|
| 查看次数: |
2551 次 |
| 最近记录: |