Qt World Summit: Register Today!

DOM Ready

  • How i know if the DOM is ready in QWebView (QFrame), like jQuery.ready()?

    I tried javaScriptWindowObjectCleared(), but this don't work.

  • I created a solution using evaluateJavaScript.


    private slots:

    void loadFinished(bool);


    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {

    // after ui->setupUi(this);
    connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));


    void MainWindow::loadFinished(bool) {

    ui->webView->page()->mainFrame()->evaluateJavaScript("function DOMReady(){if(/complete/.test(document.readyState)){return true;}return false;}");
    QVariant domready = ui->webView->page()->mainFrame()->evaluateJavaScript("DOMReady();");
    qDebug() << domready;


    There is another easier solution? POST PLEASE!

Log in to reply