Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use pic in qss
Forum Updated to NodeBB v4.3 + New Features

How to use pic in qss

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 995 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lwx_me
    wrote on last edited by
    #1

    I found many software's resouces file were in one picture,like this:
    !http://www.youback.net/wp-content/uploads/2014/09/play.png(play.png)!
    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:

    @
    .QPushButton{
    background-image: url(:/image/btn-play.png);
    background-position:left top;
    /background-position:right top;/
    width:48px;
    height:48px;
    }
    @

    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??

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      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");
      ui->label->setPixmap(pix.copy(48,0,48,48));
      @

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

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved