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 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();
}
To copy to clipboard, switch view to plain text mode
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" )
}
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" )
}
To copy to clipboard, switch view to plain text mode
Btw, I always remove my html every close my application
{
QFile::remove(QDir::tempPath()+"/tahede.html");
}
void MainWindow::closeEvent(QCloseEvent *event)
{
QFile::remove(QDir::tempPath()+"/tahede.html");
}
To copy to clipboard, switch view to plain text mode
Bookmarks