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. One QML two File Html inside: how can I call javascript functions inside its from c++
Forum Update on Monday, May 27th 2025

One QML two File Html inside: how can I call javascript functions inside its from c++

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 508 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.
  • E Offline
    E Offline
    elicat
    wrote on 16 Jul 2018, 06:43 last edited by elicat
    #1

    hello,
    INTRODUCTION PROJECT

    • in my project i cannot use websocket;
    • I have one file QML with rectangle area that connetc at webengine
    • inside rectangle area there is a form HTML, so i have FORM1 and FORM2
    • I can call a C ++ function from an html button passing the values of all the elements of a FORM1 and FORM2.

    How can I call a javacript function (for example functionform1 () or functionform2 ()) from C ++ ????

    This is two areas whith two file html

    Rectangle {
    	id: boxLeft
    	EngineIndexHtml {
    		id: oldBeardedMan
    		WebChannel.id: "wiseMan"
    	}
    	WebEngineView {
    		id: viewTestEngine
    		anchors.fill: parent
    		url: "/html/form1.html"
    		webChannel: channel
    	}
    	WebChannel {
    		id: channel
    		registeredObjects: [oldBeardedMan]
    	}                        
    }
    Rectangle {
    	id: boxRight
    	EngineIndexHtml {
    		id: idPage2
    		WebChannel.id: "ChannelPage2"
    	}
    	WebEngineView {
    		id: viewTestEnginePage2
    		anchors.fill: parent
    		url: "/html/form2.html"
    		webChannel: channelPage2
    	}
    	WebChannel {
    		id: channelPage2
    		registeredObjects: [idPage2]
    	}
    

    This is one connect webengine in HTML (form1)

            window.onload = function () {
                new QWebChannel(qt.webChannelTransport, function (channel) {
                    webobj = channel.objects.wiseMan;
                    window.foo = webobj;
                });
            }
    

    So i can call a function C++ from html file. For example :

    foo.retriveElementValue(array_parameter);
    

    Saluti, Gianfranco Elicat

    1 Reply Last reply
    0

    1/1

    16 Jul 2018, 06:43

    • Login

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