Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebView works perfectly in Qt4.8, fails in Qt5.0

QWebView works perfectly in Qt4.8, fails in Qt5.0

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neveralull
    wrote on last edited by
    #1

    I have a QWebView that opens a local web page on my computer, and everything works perfectly in Qt4.8. (It also works with a browser). But after porting the software to Qt5.0 (and making the change from QWebView to QtWebKitWidgets/QWebView, I get the failure return from loadFinished().

    Here's the code: @HelpManager::HelpManager(QObject *parent) :
    QObject(parent)
    {
    view = new QWebView();
    connect (view, SIGNAL(loadStarted()), SLOT(loadIsStarted()));
    connect (view, SIGNAL(loadProgress(int)), SLOT(loadInProgress(int)));
    connect (view, SIGNAL(loadFinished(bool)), SLOT(loadIsFinisehd(bool)));
    view->load(QUrl("../Help/IDTNVMeMgr-web/index.html"));
    view->setWindowTitle("IDTVMeMgr Help Information");
    view->show();
    }
    void HelpManager::loadIsStarted()
    {
    qDebug() << "loadIsStarted";
    }

    void HelpManager::loadInProgress(int progress)
    {
    qDebug() << "loadInProgress, progress =" << progress;
    }

    void HelpManager::loadIsFinisehd(bool isOk)
    {
    qDebug() << "loadIsFinshed, status = " << isOk;
    } @

    Here is the successful output using Qt4.8

    @loadIsStarted
    loadInProgress, progress = 10
    loadInProgress, progress = 10
    loadInProgress, progress = 27
    loadInProgress, progress = 29
    loadInProgress, progress = 32
    loadInProgress, progress = 36
    loadInProgress, progress = 36
    loadInProgress, progress = 36
    loadInProgress, progress = 90
    loadInProgress, progress = 90
    loadInProgress, progress = 90
    loadInProgress, progress = 90
    loadInProgress, progress = 90
    loadInProgress, progress = 100
    loadIsFinshed, status = true @

    And here is the failure using Qt5.0

    @loadIsStarted
    loadInProgress, progress = 10
    loadIsFinshed, status = false
    loadInProgress, progress = 100 @

    Does anybody have any ideas?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      At a guess, the process' current working directory is not what you think it is rendering the relative path (line 8) to the file invalid.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neveralull
        wrote on last edited by
        #3

        I too suspected that it wasn't finding the file at the relative path, however, I added qDebug() << "curDir = " << QDir::currentPath();
        and it returned the correct path. Also I added a call to
        File::exists ("../Help/IDTNVMeMgr-web/index.html") and it returned true. Finally I changed the path in load(QUrl("../) from a relative path to an absolute path, and still got the same failure.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          Well I guess the next stop is to subclass QWebPage, implement extension()/supportsExtension() and handle QWebPage::ErrorPageExtension calls. You should receive an ErrorPageExtensionOption object containing a useful error message.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            neveralull
            wrote on last edited by
            #5

            I put solving this problem aside due to other pressing concerns, however I need to get it to work now. I have since upgraded to Qt5.02, and for the MSVC++ version, I still get the same results as above. But for the Qt5.02 MinGW version, it is even worse. The program at first seems to hang, but after a long time, it crashes with the following output:
            QIODevice::read: maxSize argument exceeds QByteArray size limit.
            terminate called after throwing an instance of 'std::bad_alloc'
            what(): std::bad_alloc

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              Completely untested, but IIRC Qt 5 is way more picky about QUrls... Try using
              @view->load(QUrl::fromLocalFile("../Help/IDTNVMeMgr-web/index.html"));@

              1 Reply Last reply
              0
              • N Offline
                N Offline
                neveralull
                wrote on last edited by
                #7

                The suggested change at least keeps the program from crashing for Qt5.02 MinGW version, but I still only get a black window displayed.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved