[Qtwebengine] Handle frames and web forms with QWebEngine

NoRulez norulez at me.com
Wed Feb 17 15:41:12 CET 2016


Hi Allan,
hi eduard,

I got it. I will post a complete example when everything is working as expected. Maybe the example could also be added to Qt.

Thanks


> Am 16.02.2016 um 23:00 schrieb NoRulez <norulez at me.com>:
> 
> But how can i fire a javascript signal if an iframe content is changed? What I'm doing with the variable "var content"?
> So what functions did I need to call? If I am the owner of the website I could maybe inject something like "<body onload=''>". I don't want to do a lot of JavaScript coding because I hate JavaScript and I'm a c++ coder. My problem is that I need to port a WebKit app to the webengine.
> 
> The only thing why I need it is because the Qt guys removed WebKit and replaced it with this ... stuff (which is much more complicated if someone doesn't code JavaScript at all)
> 
> Best Regards
> 
>> Am 16.02.2016 um 17:33 schrieb Allan Sandfeld Jensen <allan.jensen at theqtcompany.com>:
>> 
>> Even without modifying the html site, you can run javascript on it, using the 
>> QWebEnginePage::runJavaScript API. Just be aware that it is asynchronous, so 
>> you get the results as a callback.
>> 
>> We included an example of how to use qtwebchannel in Qt 5.6, check out the  
>> markdowneditor example. It basically boils down to this on the C++side:
>>  QWebChannel *channel = new QWebChannel(this);
>>  channel->registerObject(QStringLiteral("content"), &m_content);
>>  page->setWebChannel(channel);
>> 
>> And including qwebchannel.js on the JavaScript side. And then using code like 
>> this to get to the "content" object:
>> new QWebChannel(qt.webChannelTransport,
>>  function(channel) {
>>    var content = channel.objects.content;
>>  }
>> }
>> 
>> 
>> Using qtwebchannel on foreign content is harder, and until Qt 5.7 brings a 
>> security risk in that any objects you inject can be reached by the remote 
>> content too. The main difference to the markdowneditor example though is just 
>> that you need to inject qwebchannel.js using either runJavaScript on the new 
>> QWebEngineScript api. 
>> 
>> Best regards
>> 
>>> On Tuesday 16 February 2016, NoRulez wrote:
>>> Since it isn't documented very well.
>>> Could you please give me a small example.
>>> 
>>> Best regards
>>> 
>>>> Am 16.02.2016 um 00:17 schrieb NoRulez <norulez at me.com>:
>>>> 
>>>> But i doesn't have access to modify the html site, I have only an url.
>>>> 
>>>> I don't know how to work with QWebChannel, since I'm not familiar with
>>>> JavaScript and I doesn't find out which function I can use from the
>>>> qwebchannel.js
>>>> 
>>>> Could you please help me?
>>>> Sorry but it was much easier with WebKit. :-(
>>>> 
>>>> Best Regards
>>>> 
>>>>>> Am 15.02.2016 um 22:10 schrieb Allan Sandfeld Jensen
>>>>>> <allan.jensen at theqtcompany.com>:
>>>>>> 
>>>>>> On Thursday 04 February 2016, NoRulez wrote:
>>>>>> Hello,
>>>>>> 
>>>>>> what is the preferred way to handle web forms (iterate over it like
>>>>>> QWebCollection does in QWebKit), search for frames by name and get
>>>>>> notified when a frame is created? (Was a signal in QWebKit)
>>>>>> 
>>>>>> Thanks in advance
>>>>> 
>>>>> I would suggest handling web-forms it in JavaScript. To get a signal
>>>>> from JavaScript, you should check out QtWebChannel, with that you can
>>>>> install QObjects in DOM then call any function from an event listener.
>>>>> 
>>>>> Best regards
>>>>> `Allan
>>>> 
>>>> _______________________________________________
>>>> QtWebEngine mailing list
>>>> QtWebEngine at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/qtwebengine
>> 
>> 
>> -- 
>> 
>> The Qt Company
>> Rudower Chausse 13, 12489 D-Berlin
>> 
>> The Qt Company is a group company of Digia Plc, 
>> Valimotie 21, FI-00380 Helsinki Finland
> _______________________________________________
> QtWebEngine mailing list
> QtWebEngine at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qtwebengine



More information about the QtWebEngine mailing list