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 <[email protected]> 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 >
_______________________________________________ webkit-qt mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-qt
