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

Ramakanth Kesireddy rama.kesi at gmail.com
Fri Aug 7 07:50:52 PDT 2020


Any feedback on the background-image:url not being displayed though the
image in the same directory?

On Thu, 6 Aug, 2020, 21:56 Ramakanth Kesireddy, <rama.kesi at gmail.com> wrote:

> Hello Konstantin,
>
> Tried to use setUserStyleSheetUrl from qrc instead of setting
> setUserStyleSheetUrl( QUrl::fromLocalFile) as mentioned in the below code
> snippet.
>
> The stylesheet is applied but local image using
> background-image:url(arrow_right.png) in the .css is not set .
>
> html,css and image are in the same directory.
>
> Appreciate your help to fix the background-image not being set.
>
> Best Regards,
>
> Ramakanth
> On Wed, Aug 5, 2020 at 10:54 PM Ramakanth Kesireddy <rama.kesi at gmail.com>
> wrote:
>
>> 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/20200807/a64d067c/attachment.htm>


More information about the webkit-qt mailing list