[webkit-qt] setUserStyleSheetUrl is not working in QtWebkit 5.212 Alpha4

Ramakanth Kesireddy rama.kesi at gmail.com
Wed Aug 5 10:24:07 PDT 2020


Hi,

When we ported from old Qt webkit(corresponding to Qt 4.8) to Qt Webkit
5.212 alpha4 based Qt 5.6.3, the stylesheet is not applied using
setUserStyleSheetUrl ().

Here is the sample code snippet:

ui->webView->setContextMenuPolicy( Qt::NoContextMenu );

ui->webView->settings()->setUserStyleSheetUrl( QUrl::fromLocalFile(
QString::fromStdString( "user.css" ) ) );

 ui->webView->settings()->setDefaultTextEncoding( "utf-8" );

ui->webView->setFocusPolicy(Qt::NoFocus);

 QFile file ("scrolltest_page.html");

 if (file.exists())

    {

        file.open(QIODevice::ReadOnly);

        QByteArray htmlArr = file.readAll();

        QString htmlStr = QString::fromUtf8(htmlArr);

        ui->webView->setHtml(htmlStr);

        file.close();
    }

Sample user.css and scrolltest_page.html are attached herewith.
As the stylesheet is not applied, the buttons with background color and
style set using css is not working.

Please let me know if there is any known issue or any issue with attached
user.css with respect to Qtwebkit 5.212 alpha4.
Also can we add the images to qrc and refer the same in user.css?

The same css works in old Qt webkit along with setUserStyleSheet.

Appreciate for your quick response in this regard.

Best Regards,
Ramakanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20200805/434ba513/attachment.htm>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20200805/434ba513/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: user.css
Type: text/css
Size: 3330 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20200805/434ba513/attachment.css>


More information about the webkit-qt mailing list