zoukankan      html  css  js  c++  java
  • QT 操作记录,待实践

    一、C++实现

        QWebFrame* frame = webView()->page()->currentFrame();
        if (frame!=NULL){
            QWebElementCollection collection1 = frame->findAllElements(“input[name=submit]”);
            foreach (QWebElement element, collection1){
    
                QPoint poss(element.geometry().center());
                QPoint pos = this->topLevelWidget()->mapToGlobal(QPoint(0,0));
                QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QApplication::sendEvent(webView->page(), &event0);
                QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
                QApplication::sendEvent(webView->page(), &event1);
            }
        }
    

    这种方法对于纯HTML的网页有效,但是javascript实现提交功能的网页不一定有效。

    二、javascript实现

    调用

    evaluateJavaScript(code);


    三、两者结合实现

        QWebFrame* frame = webView()->page()->currentFrame();
        if (frame!=NULL) {
            QWebElementCollection collection1 = frame->findAllElements(“input[name=submit]”);
            foreach (QWebElement element, collection1){
                element.evaluateJavaScript("this.click();");
            }
        }
    
    


     

  • 相关阅读:
    Linux线程(一)
    模板(一)
    C++基础(八)
    C++基础(七)
    C++基础(六)
    C++基础(五)
    2.C#基础(二)
    1.C#基础(一)
    2.给出距离1900年1月1日的天数,求日期
    网络协议破解 SMTP
  • 原文地址:https://www.cnblogs.com/eaglezzb/p/4176463.html
Copyright © 2011-2022 走看看