PDA

View Full Version : QWebView problem



wirasto
18th November 2009, 23:50
I try show a html file in webview, but I surprised because me always get a blank page.
I generate a html file with my function call htmlgenerate(). The file is created with successful, but I don't know why webview just give me a blank page. If I use firefox for display my html file, everything is fine.

This is my code for display



void Dialog::showHtml()
{
htmlgenerate(); // save to QDir::tempPath ()+"/tahede.html"

Viewer *lap0=new Viewer(this);
lap0->setPage(QUrl(QDir::tempPath()+"/tahede.html"));
lap0->reload();
lap0->exec();
}





void Viewer::setPage(QUrl url)
{
//web is QWebView
m_ui->web->setUrl(url);
}


void Viewer::reload()
{
m_ui->web->reload();
qDebug() << m_ui->web->url(); // result always QUrl( "about:blank" )
}



Btw, I always remove my html every close my application


void MainWindow::closeEvent(QCloseEvent *event)
{
QFile::remove(QDir::tempPath()+"/tahede.html");
}

kichi
19th November 2009, 01:55
void Viewer::setPage(QUrl url)
{
//web is QWebView
m_ui->web->setUrl(url);
}



Perhaps, you should use load() instead of setUrl(), or you should call load() after calling setUrl()

kichi
19th November 2009, 02:32
void Viewer::setPage(QUrl url)
{
//web is QWebView
m_ui->web->setUrl(url);
}



Perhaps you should change the name of your setPage(), because QWebView already has setPage().