Applying custom stylesheet to QWebView

2019-05-13 19:36发布

My Qt application loads an external html page within a QWebView widget. How can I define my own stylesheet to present the content of the page? Is it possible to bundle a .css file for QWebView to pick up?

标签: css qt qwebview
1条回答
Deceive 欺骗
2楼-- · 2019-05-13 19:58

You can load it with the settings of your QWebView :

QWebView myView;
QWebSettings * settings = myView->settings();
QUrl myCssFileURL;
settings->setUserStyleSheetUrl(myCssFileURL);
查看更多
登录 后发表回答