[Solved]How to change dynamically QWebFrame contents?
-
wrote on 12 Jun 2011, 15:05 last edited by
Dear all friends,
I would like to know how to change dynamically QWebFrame contents?
Thanks
-
wrote on 12 Jun 2011, 15:56 last edited by
Could you be a little more specific? Do you mean the "load() function":http://doc.qt.nokia.com/4.7-snapshot/qwebframe.html#load ?
-
wrote on 12 Jun 2011, 17:21 last edited by
No, I want to set setHtml() function & want to show newly set html on webframe...
Thanks -
wrote on 12 Jun 2011, 17:45 last edited by
Well, AFAIK, setHtml should change the content immediately. If you are looking for a widget (not a frame inside an already exiting Page/Widget), you should use "QWebView":http://doc.qt.nokia.com/4.7-snapshot/qwebview.html
-
wrote on 12 Jun 2011, 19:40 last edited by
I found some reason,
I set view-> setHtml(newHtml);They change but, change to original just after finished
I think that may connect with changeUrl signal but I can't find out..Plz help me
Thanks -
wrote on 12 Jun 2011, 20:12 last edited by
Hi zither,
Could you post the related code of your WebView. Firstly, the setHtml will cause the loadFinished signal to be posted again, causing an infinite loop. I have attached working code of what you want to do.
@
#include "mainwindow.h"
#include "ui_mainwindow.h"#include <QtWebKit/QWebView>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool))); ui->webView->load(QUrl("http://www.google.com"));
}
MainWindow::~MainWindow()
{
disconnect(ui->webView, 0, this, 0);delete ui;
}
void MainWindow::slotloadFinished(bool okay)
{
disconnect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool)));ui->webView->setHtml("<html><body>test</body></html>"); connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(slotloadFinished(bool)));
}
@ -
wrote on 12 Jun 2011, 20:15 last edited by
Instead of the disconnect and connect, you could do this..
@
void MainWindow::slotloadFinished(bool okay)
{
ui->webView->blockSignals(true);ui->webView->setHtml("<html><body>test</body></html>"); ui->webView->blockSignals(false);
}
@ -
wrote on 12 Jun 2011, 20:36 last edited by
It's work.. :)
Thanks to all -
wrote on 12 Jun 2011, 23:06 last edited by
Good to hear that. Also, could you please add [Solved] in front of the title (by editing the first post).
1/10