[webkit-qt] Question on reloading changed CSS

Harri Pasanen grego at mpaja.com
Wed Oct 5 01:52:06 PDT 2011


Hi,

I'm using Qt 4.7.4.

I have some code that rewrites CSS and then shows the new page.

To my surprise, the first attempt with:

    writeCSS();
    ui->browser->reload();

did not work.  Eventually after a while the new CSS was taken into account, 
but not immediately.

I then delved into docs a bit, and tried:

    writeCSS();
    ui->browser->triggerPageAction(QWebPage::ReloadAndBypassCache);

which seemed to speed up the recognition of changed CSS, but it still was not 
immediate.


In the end I resorted following trickery:

    writeCSS();
    ui->browser->history()->clear();
    ui->browser->triggerPageAction(QWebPage::ReloadAndBypassCache);
    QTimer::singleShot(100, ui->browser, SLOT(reload()));

which seems to work, but is a bit hacky.
The singleShot timer is required for *the very first time* CSS changes, 
subsequently it seemed to work without it. As the pages I'm displaying are 
very short, it does not seem to do any harm doing it every time.

I don't have Qt sources on this machine (yet), so I did not go down that 
route.

Anything obvious/subtle that I'm missing, or is the above a bug?


Harri



More information about the webkit-qt mailing list