开发者

How to change qwebview's background image, color and font color

I want to change my webview's background image, color and font color. I tried setBackgroundRole method but it only have few color. It doesn't have the color that I want. And I don't find how to set font color and background image. Do you have any ideas to solve this开发者_运维知识库 thing?


Use html for that, QWebView is just a container for QWebPage, where you can set all you need in page's html code.


Use QWidget::setPalette() to set your own QPalette. With this you can freely choose colors for each role.

To have an image as a background you would have to derive your own class from QWebView and override paintEvent() I think.


use setHtml function

QString htmlhead = "<head><style>body {\n   background-color: #eee;\nbackground-image: url("+QUrl("qrc:/new/prefix1/back.png").toString()+");";
ui->webView->setHtml(htmlhead);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜