How to use pic in qss

  • I found many software's resouces file were in one picture,like this:
    This is a button's different state of press, hover...and they were designed in one picture.
    I can use first or last sub pic by this qss:

    background-image: url(:/image/btn-play.png);
    background-position:left top;
    /background-position:right top;/

    The background-position of QSS has no equivalent in CSS2 or CSS3. It has no background-position-x background-position-y.

    How to use the second or third in QSS??

  • Moderators


    AFAIK, you can't do it from stylesheets. It doesn't yet implement full CSS. But you can do it easily using QPixmap functions. For eg.
    QPixmap pix(":/play.png");

    This will display the image with x-offset of 48px on the QLabel.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.