Search Results

Search found 8 results on 1 pages for 'qwebelement'.

Page 1/1 | 1 

  • Trying to issue a mouseclick event on a QWebElement in QWebView QtWebKit

    - by Bad Man
    I'm trying to send a mouse click event on a certain element in the QtWebKit DOM but I'm obviously doing it wrong: QWebElement el=this->page()->mainFrame()->findFirstElement("input[type=submit]"); el.setFocus(); QMouseEvent pressEvent(QMouseEvent::MouseButtonPress, el.geometry().center(), Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this->page()->mainFrame(), &pressEvent); QMouseEvent releaseEvent(QMouseEvent::MouseButtonRelease, el.geometry().center(), Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this->page()->mainFrame(), &releaseEvent); Any ideas? (p.s. I am extending QWebView if it wasn't obvious)

    Read the article

  • LIbrary issue: How do I set up QtWebKit to parse HTML?

    - by user560106
    Nick Presta showed that you can parse HTML with qt here: Library Recommendation: C++ HTML Parser However, when I attempt to build this, I get an access violation on the "QWebFrame* frame = page.mainFrame();" line. What am I doing wrong? #include <QtWebKit\QWebElement> #include <QtWebKit\QWebView> #include <QtWebKit\QWebFrame> #include <QtWebKit\QWebPage> #include <iostream> int main() { QWebPage page; QWebFrame* frame = page.mainFrame(); frame->setHtml( "<html><head></head><body></body></html>" ); QWebElement document = frame->documentElement(); return 0; }

    Read the article

  • JavaScript or Qt way to update a select box value?

    - by Pirate for Profit
    So I have the following HTML and am trying to change which item is selected. <select name="coolselectbox"> <option value="default" selected="selected">---</option> <option value="something">Something</option> <option value="something-else">Something Else</option> </select> Here's what I've tried: QWebElement defaultOpt = this->page()->mainFrame()->findFirstElement("option[value=default]"); QWebelement somethingOpt = this->page()->mainFrame()->findFirstElement("option[value=something]"); defaultOpt.removeAttribute("selected"); somethingOpt.setAttribute("selected", "selected"); And then also: QWebElement selectBox = this->page()->mainFrame()->findFirstElement("select[name=coolselectbox]"); selectBox.setAttribute("value", "something-else"); However neither of these seems to get the job done. Does anyone know a Qt solution, or is there perhaps some JavaScript snippet I can run to do this?

    Read the article

  • Using Qt to read and parse html files with QWebKit?

    - by Alberto Toglia
    I would like to read and parse certain elements of html files but I'm not interested in rendering it in any way. Basically I would like to go through all my div tags and get some of its style attributes. This is what I've done so far: QWebPage page; QWebFrame * frame = page.mainFrame(); QUrl fileUrl("localFile.html"); frame->setUrl(fileUrl); QWebElement document = frame->documentElement(); QWebElementCollection elements = document.findAll("div"); foreach (QWebElement element, elements){ std::cout << element.attribute("style").toStdString() << std::endl; } Doesn't show anything. I'm somewhat confused if I could use webkits this way. P.D.: I'm using a filechooser to pick the local html root.

    Read the article

  • Accessing html form input type=text using jquery from a windows forms webbrowser-control

    - by simply-tom
    I have two elements on my Windows Forms application: Webbrowser-Control Button Inside of the webbrowser-control I show a very simple html-form with two input type=text. I press the button and get access to both text fields. Last year at the Qt developer conference there was a quite good presentation: http://labs.trolltech.com/blogs/2009/04/17/jquery-and-qwebelement/ void highlightAllLinks() { QString code = "$('a').each( function () { $(this).css('background-color', 'yellow') } )"; view-page()-mainFrame()-evaluateJavaScript(code); } But I have to do this with .net and Windows Forms. Anyone knowing a good tutorial? Best regards,Tom

    Read the article

  • Qt: Force QWebView to click on a web element, even one not visible on the window

    - by Pirate for Profit
    So let's say I'm trying to click a link in the QWebView, here is what I have: // extending QWebView void MyWebView::click(const QString &selectorQuery) { QWebElement el = this->page()->mainFrame()->findFirstElement(selectorQuery); if (!el) return; el.setFocus(); QMouseEvent pressEvent(QMouseEvent::MouseButtonPress, el.geometry().center(), Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this, &pressEvent); QMouseEvent releaseEvent(QMouseEvent::MouseButtonRelease, el.geometry().center(), Qt::MouseButton::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(this, &releaseEvent); } And you call it as so: myWebView->click("a[href]"); // will click first link on page myWebView->click("input[type=submit]"); // submits a form THE ONLY PROBLEM IS: if the element is not visible in the window, it is impossible to click. What I mean is if you have to scroll down to see it, you can't click it. I imagine this has to do with the geometry, since the element doesn't show up on the screen it can't do the math to click it right. Any ideas to get around this? Maybe some way to make the window behave like a billion x billion pixels but still look 200x200?

    Read the article

  • Qt - QWebView Problem

    - by user547057
    Hi, I have a PyQt gui script which consists of a QWebView widget. I'm trying to send a GET request, i.e go to a page, fill a form and hit click using the code at the bottom of this question. Since i'm dealing with the documentElement(a QWebElement) of the webview, I need to place all DOM actions in a separate function(which I have named fillForm) and connect the loadFinished() signal into the function. Without connecting the signal, the document will not have loaded and I won't be able to get the elements I want. I'm able to submit the form correctly and get the proper response from the webpage. The problem i'm having is that, the above leads to a sort of infinite loop. This is because the webpage gets reloaded each time a new page is loaded, so the form gets filled each and every single time without stopping. I'd like to know if there's some way of finding out whether the WebView's page has loaded fully, non-asynchronously or maybe pause execution of the script(without freezing the gui) until the whole document has loaded. I'm unable to come up with a satisfactory solution(my idea consisted of keeping a global variable to track clicks) to this problem. I would appreciate it if someone could help me out with a better way to tackle this. Thanks! Here's the code i'm using import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * from PyQt4 import QtCore app = QApplication(sys.argv) web = QWebView() web.load(QUrl("http://mywebsite.com")) def fillForm(): doc = web.page().mainFrame().documentElement() searchform = doc.findFirst("input[type=text]") searchform.setAttribute("value", "hello") button = doc.findFirst("input[type=submit]") button.evaluateJavaScript("click()") QtCore.QObject.connect(web, QtCore.SIGNAL("loadFinished"), fillForm) web.show() sys.exit(app.exec_())

    Read the article

1