Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QWebEngineView - loadFinished triggered twice for one setUrl?
QtWS25 Last Chance

QWebEngineView - loadFinished triggered twice for one setUrl?

Scheduled Pinned Locked Moved Solved QtWebEngine
6 Posts 3 Posters 4.2k Views
  • 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.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    I have a slot that is connected like this, used to setup my WebChannel for communication

    connect(ui->webView_studio, SIGNAL(loadFinished(bool)), this, SLOT(createWebChannelStudio()));
    

    the slot is executed two times, and I don't know why, I just set the Url once for the webView.
    I could put an integer and only execute the code if the count is ==2 but that is not really clean.
    It is possible to know why loadFinished signal is called twice?
    Thanks


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bui Trung
      wrote on last edited by
      #2

      try to pass a boolean parameter to your slot createWebChannelStudio -> createWebChannelStudio(bool), check if this value is true (load finished success) then do the things you need. I don't know if it cause because of mismatch parameter between your signal and slot ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3

        Try to connect to the page() signal instead:

            connect(webView->page(),SIGNAL(loadFinished(bool)),this, SLOT(loadFinished(bool)));
        

        If I remember well, it resolves this issue for me.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #4

          Hmm thanks for the advice guys, but I am still having the issue.
          Seems like a bug? Signal is emitted twice with "true" each time as parameter.

              connect(ui->webView_plan->page(), SIGNAL(loadFinished(bool)), this, SLOT(createWebChannelPlan(bool)));
          

          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maximus
            wrote on last edited by maximus
            #5

            I think this could be the cause, Designer create this auto-generated code:

                webView_plan = new QWebEngineView(tab_trainingPlans);
                webView_plan->setObjectName(QStringLiteral("webView_plan"));
                webView_plan->setContextMenuPolicy(Qt::NoContextMenu);
                webView_plan->setProperty("url", QVariant(QUrl(QStringLiteral("about:blank"))));
            

            In designer, my QWebEngineView has a "dynamic properties" called "url" that I can't seem to remove.


            Free Indoor Cycling Software - https://maximumtrainer.com

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by maximus
              #6

              Fixed by removing the dynamic property "url" in Designer. You can remove with the - bar on top right, I was expecting right click.
              I suspect it is because my object were QWebView that are demoted to QWidget and promoted to QWebEngineView, the dynamic property of QWebView were still there
              Thanks guys


              Free Indoor Cycling Software - https://maximumtrainer.com

              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