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.

    mainwindow.h:

    @
    private slots:

    void loadFinished(bool);
    @

    mainwindow.cpp:

    @
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.