PDA

View Full Version : QT implentation for interacting with web widget



ravikumar
22nd January 2012, 09:45
Hi,
I am new to this QT.I have to implement a small code that loads a server webpage which contain a javascript widget(create submit button).Now I need to get events to QT code when user submits the javascript button.
Please let me know how to do this any example or code snippets appreciated.

Note:
I should not edit javascript.

Thank you.

MrShahi
23rd January 2012, 08:39
Hi , I think you can use QWebkit and QWebFrame class to solve your problem..

ravikumar
23rd January 2012, 10:37
Hi ,
Thanks for the reply. I have studied this webkit and webframe classes.I am not getting Idea for this.I can do this if i can able to edit javascript by exposing QT object and connect API.But I shouldnot edit javascript there is the tricky.

Thanks,

wysota
23rd January 2012, 14:30
QWebElement elem = webFrame->findFirst("INPUT[type=submit]");
elem.evaluateJavascript("this.click();");

or similar.

ChrisW67
23rd January 2012, 21:39
The impression I got was that ravikumar wanted to be signalled when the user clicked the Javascript-laden button, rather than programmatically clicking the button.

wysota
23rd January 2012, 22:05
Ah... maybe so...


QWebFrame *frame = ...
QObject *obj = new MyObject(...);
frame->addToJavaScriptWindowObject("someObject", obj);
QWebElement elem = webFrame->findFirst("INPUT[type=submit]");
elem.setAttribute("onClick", "window.someObject.doSomething()");
// or something like this:
frame->evaluateJavaScript("document.getElementById('submitbutton').addEventLi stener('click', window.someObject.doSomething)");