Results 1 to 1 of 1

Thread: QStyleSheets: background position using pixels problem

  1. #1
    Join Date
    Mar 2006
    Argentina - CABA
    Thanked 1 Time in 1 Post
    Qt products

    Default QStyleSheets: background position using pixels problem

    Hi guys,

    Recently I've started to implement CSS sprite method in my Application Skinning (which uses QStyleSheets). In many cases, i use border-image for positioning those images and styling a widget (like QPushButton and widgets that are no fixed, so that background could be stretched).
    Now, in other hand i have fixed widgets, in which case i used to use background property in the css style. Since i want to migrate those to CSS sprite method as well, I found that i cant (does not work or i am doing it wrong) specidy the position of the image inside the sprite with pixels (it works when you use top, center, left, etc. but not when you use pixels as the position of the background-position).

    Here is my example:

    Qt Code:
    1. QPushButton#minimizeWindowButton {
    2. border: 0;
    3. background: url(windowButtons.png) -0px 0px;
    4. width: 20px;
    5. height: 20px;
    6. }
    7. QPushButton#minimizeWindowButton:hover {
    8. background: url(windowButtons.png) -20px 0px;
    9. }
    10. QPushButton#minimizeWindowButton:pressed {
    11. background: url(windowButtons.png) -40px 0px;
    12. }
    13. QPushButton#closeWindowButton {
    14. border: 0;
    15. background: url(windowButtons.png) -60px 0px;
    16. width: 20px;
    17. height: 20px;
    18. }
    19. QPushButton#closeWindowButton:hover {
    20. background: url(windowButtons.png) -80px 0px;
    21. }
    22. QPushButton#closeWindowButton:pressed {
    23. background: url(windowButtons.png) -100px 0px;
    24. }
    To copy to clipboard, switch view to plain text mode 

    This does not work, in both buttons shows the same image and the hover and pressed does not exist.
    Now, this works perfectly if I use border-image. Also, you see changes if you use positions properties like top, middle, center, etc. But in this case, is not useful since i need to specify the position in pixels.

    Any Idea? Does Qt does not support it?

    I am attaching the .ui (which includes the stylesheet already) and the sprite image if someone want to test. Just have in mind to change the image path of the sprite.

    Thanks in advance.

    Attached Images Attached Images
    Attached Files Attached Files
    Gustavo A. DÃ*az

Similar Threads

  1. Replies: 3
    Last Post: 3rd September 2012, 08:32
  2. QLabel and its content (pixmap) position problem.
    By miqqo in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2010, 10:57
  3. Replies: 4
    Last Post: 3rd August 2010, 13:30
  4. QwtLegend Position changing problem?
    By umituzun84 in forum Qwt
    Replies: 1
    Last Post: 19th March 2010, 14:25
  5. QGraphicsScene Position Problem
    By addu in forum Qt Programming
    Replies: 14
    Last Post: 22nd July 2009, 15:38


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.