Nominate our 2022 Qt Champions!

Background-image in local file using setUserStyleSheetUrl()

  • hello, i have a project with Qt application who use QWebView to appli a CSS file.
    The server HTTP is in a µC, i want use CSS for add style (image...) in my QT application.
    i use setUserStyleSheetUrl() to apply my CSS file.

    it's work.
    i want store image in qt application, not on server HTTP.

    @#img {
    background-image: url("img.bmp");
    border:1px black solid;
    background-color: #C2C7CB;

    But background-image not work. img.bmp is next to style.css.

    i have try also to use qrc, my image is in qrc.
    i copy path or url but not work.
    @background-image: url("qrc:/CSS/CSS/img.bmp");@

    @ background-image: url(":/CSS/CSS/img.bmp");@

    Can you help me please?

  • Check this one......"CSS Image Help":

    Hope it will help you.


  • Just a suggestion - will it work with *.png or *.gif instead...
    Perhaps the plugin can't load BMP or you're missing image format plugins

    P.S. also if you're using old version (4.x) that bug probably isn't fixed yet :-)

Log in to reply