Results 1 to 3 of 3

Thread: QWebView problem

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question QWebView problem

    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

    Qt Code:
    1. void Dialog::showHtml()
    2. {
    3. htmlgenerate(); // save to QDir::tempPath ()+"/tahede.html"
    4.  
    5. Viewer *lap0=new Viewer(this);
    6. lap0->setPage(QUrl(QDir::tempPath()+"/tahede.html"));
    7. lap0->reload();
    8. lap0->exec();
    9. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. void Viewer::setPage(QUrl url)
    2. {
    3. //web is QWebView
    4. m_ui->web->setUrl(url);
    5. }
    6.  
    7.  
    8. void Viewer::reload()
    9. {
    10. m_ui->web->reload();
    11. qDebug() << m_ui->web->url(); // result always QUrl( "about:blank" )
    12. }
    To copy to clipboard, switch view to plain text mode 


    Btw, I always remove my html every close my application
    Qt Code:
    1. void MainWindow::closeEvent(QCloseEvent *event)
    2. {
    3. QFile::remove(QDir::tempPath()+"/tahede.html");
    4. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView problem

    Quote Originally Posted by wirasto View Post

    Qt Code:
    1. void Viewer::setPage(QUrl url)
    2. {
    3. //web is QWebView
    4. m_ui->web->setUrl(url);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Perhaps, you should use load() instead of setUrl(), or you should call load() after calling setUrl()
    kichi

  3. #3
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView problem

    Quote Originally Posted by wirasto View Post

    Qt Code:
    1. void Viewer::setPage(QUrl url)
    2. {
    3. //web is QWebView
    4. m_ui->web->setUrl(url);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Perhaps you should change the name of your setPage(), because QWebView already has setPage().
    kichi

Similar Threads

  1. QWebView problem with pdf
    By oscar in forum Qt Programming
    Replies: 5
    Last Post: 23rd August 2008, 15:37
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. QWebView unknown problem
    By morfei in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 00:12
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.