QT program tips

1、QT QWebengine運行JavaScript獲取圖片的數量

pView->page()->runJavaScript("document.getElementsByTagName(\"img\").length", []
(QVariant result) {
qDebug() << result.toString();
});

或者

struct GetElementCountFunctor {
GetElementCountFunctor(){ }
void operator()(const QVariant &result) {
    qDebug() << result.toString();
    }
};

pView->page()->runJavaScript("document.getElementsByTagName(\"img\").length", GetElementCountFunctor());


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章